-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Failed attempt at getting camera to work on worker
- Loading branch information
1 parent
a7ebcf9
commit e181847
Showing
7 changed files
with
107 additions
and
85 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import raspberryPiCamera from "raspberry-pi-camera-native"; | ||
import { BehaviorSubject } from "rxjs"; | ||
import { first } from "rxjs/operators"; | ||
import { IFacePoint } from "./interfaces"; | ||
import { cameraOptions } from "./config"; | ||
|
||
let framesSubject: BehaviorSubject<Buffer> = new BehaviorSubject<Buffer>(null); | ||
|
||
export const getFrames = async (): Promise<BehaviorSubject<Buffer>> => { | ||
await startCamera(); | ||
await runCamera(); | ||
return framesSubject; | ||
}; | ||
|
||
const startCamera = (): Promise<any> => { | ||
console.log("cameraHelper - startCamera - A"); | ||
return new Promise(resolve => { | ||
console.log("cameraHelper - startCamera - B"); | ||
raspberryPiCamera.start(cameraOptions, resolve); | ||
}); | ||
}; | ||
|
||
const runCamera = (): Promise<any> => { | ||
console.log("cameraHelper - runCamera - A"); | ||
raspberryPiCamera.on("frame", (buffer: Buffer) => { | ||
console.log("cameraHelper - runCamera - B"); | ||
framesSubject.next(buffer); | ||
}); | ||
console.log("cameraHelper - runCamera - C"); | ||
return framesSubject.pipe(first(frame => !!frame)).toPromise(); | ||
}; |
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
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 |
---|---|---|
|
@@ -28,6 +28,3 @@ const start = num => { | |
}; | ||
|
||
setup(1); | ||
setup(2); | ||
setup(3); | ||
setup(4); |