-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
430 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,4 +63,5 @@ test/spec/*.js.map | |
|
||
/.nyc_output/ | ||
/test/integration/app/spec/swagger.json | ||
/examples/*.jpeg | ||
/examples/*.jpeg | ||
.tmp |
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// This example illustrates the usecase, where you need to capture liveview from the camera | ||
// and then save it to .mjpg file. The file will be updated in live mode. | ||
|
||
const { Camera } = require('../src'); | ||
// If you launch this example not from library folder, change the previous two lines to: | ||
// const { Camera } = require('@typedproject/gphoto2-driver'); | ||
const path = require('path'); | ||
const camera = new Camera(); | ||
|
||
const NUMBER_OF_SECONDS_TO_WRITE = 10; | ||
const PATH_TO_SAVE = path.join(__dirname, '../.tmp/live.mjpg'); // Make sure that this folder exists | ||
|
||
camera.initialize(); | ||
|
||
const liveview = camera.liveview({ | ||
output: "file", | ||
fps: 24, // Number of frames per second. Default is 24. | ||
filePath: PATH_TO_SAVE, | ||
}); | ||
|
||
liveview.start(); | ||
|
||
setTimeout(() => { | ||
|
||
liveview.stop(); | ||
|
||
camera.closeQuietly(); | ||
}, NUMBER_OF_SECONDS_TO_WRITE * 1000); |
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// This example illustrates the usecase, where you need to capture liveview from the camera | ||
// and get live output of each frame as binary (Buffer) or base64 | ||
|
||
// To check if liveview works with your camera, you can just use | ||
// node examples/camera-liveview.js | xxd | grep ffd9 | ||
// if you see a lot of ffd9 (not in the first column) - then it works | ||
|
||
const { Camera } = require('../src'); | ||
// If you launch this example not from library folder, change the previous two lines to: | ||
// const { Camera } = require('@typedproject/gphoto2-driver'); | ||
const camera = new Camera(); | ||
|
||
const NUMBER_OF_SECONDS_TO_LISTEN = 10; | ||
const NUMBER_OF_SECONDS_TO_WAIT = 10; | ||
const OUTPUT = "binary"; | ||
// change these lines to see base64 output | ||
// const OUTPUT = "base64"; | ||
|
||
camera.initialize(); | ||
|
||
const liveview = camera.liveview({ | ||
output: OUTPUT, | ||
fps: 24, // Number of frames per second. Default is 24. | ||
}); | ||
|
||
liveview.on("data", (data, size) => { | ||
process.stdout.write(data); // We can not use console.log for binary, becayse it puts \n after each line | ||
}); | ||
|
||
liveview.start(); | ||
|
||
setTimeout(() => { | ||
|
||
liveview.stop(); | ||
|
||
}, NUMBER_OF_SECONDS_TO_LISTEN * 1000); | ||
|
||
setTimeout(() => { | ||
// Here we wait for NUMBER_OF_SECONDS_TO_WAIT + NUMBER_OF_SECONDS_TO_LISTEN and then | ||
// launch liveview one more time | ||
// The output should be caught by original liveview.on("data") event handler | ||
liveview.start(); | ||
|
||
setTimeout(() => { | ||
|
||
liveview.stop(); | ||
|
||
camera.closeQuietly(); // Do not forget to close camera | ||
}, NUMBER_OF_SECONDS_TO_LISTEN * 1000); | ||
}, (NUMBER_OF_SECONDS_TO_WAIT + NUMBER_OF_SECONDS_TO_LISTEN) * 1000) |
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
Oops, something went wrong.