-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from TUS-OSK/slackbot
Slackbot
- Loading branch information
Showing
7 changed files
with
405 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,9 @@ | ||
"use strict"; | ||
|
||
const photoapi = require("./photoAPI"); | ||
const NodeWebcam = require('node-webcam'); | ||
const slack = require("./slack"); | ||
const cv = require('opencv4nodejs'); | ||
|
||
|
||
const Webcam = NodeWebcam.create({ | ||
width: 1280, | ||
height: 720, | ||
quality: 100, | ||
|
||
delay: 0, | ||
saveShots: true, | ||
device: false, | ||
callbackReturn: "buffer", | ||
verbose: false | ||
}); | ||
|
||
/** | ||
* 写真を撮影しGooglePhotoへとアップロード,その共有リンクを取得します | ||
* @param {oAuth2Client} oAuth2Client - photoapi.getOAuthToken関数で取得します | ||
* @param {Object} album | ||
* @returns {Promise<void>} | ||
*/ | ||
module.exports.capture = async (oAuth2Client, album) => { | ||
const photo = await new Promise((resolve, reject) => { | ||
Webcam.capture("capture", (err, photo) => { | ||
if (err) { | ||
reject(err) | ||
} | ||
resolve(photo) | ||
}) | ||
}).catch(e => { | ||
console.error(e); | ||
console.error( | ||
"READMEに従ってカメラを使えるようにしてください\n" + | ||
"また,OSやセキュリティソフトでカメラへのアクセスをブロックしている可能性もあります 解除してください\n"); | ||
process.exit(1) | ||
}); | ||
const uploadToken = await photoapi.uploadPhoto(oAuth2Client, photo, Date().toLocaleString()); | ||
const {mediaItem} = await photoapi.createAlbumMediaItem(oAuth2Client, album.id, uploadToken, ""); | ||
const {baseUrl} = await photoapi.getMediaItem(oAuth2Client, mediaItem.id); | ||
return baseUrl | ||
}; | ||
module.exports.capture = async (devicePort = 0, ext = ".png") => { | ||
const cap = new cv.VideoCapture(devicePort); | ||
const frame = cap.read(); | ||
return cv.imencode(ext, frame); | ||
}; |
Oops, something went wrong.