Created
August 1, 2018 23:17
-
-
Save gastonambrogi/e9755a27dc72130d8724b08bc87cca67 to your computer and use it in GitHub Desktop.
Gets a frame from CameraPlugin Pharo package. It waits for the camera start, and returns the photo after waiting for a valid frame (that's not a blank frame.).
This file contains hidden or 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
getFrameForCamera: camNum | |
| f n | | |
(self cameraIsOpen: camNum) | |
ifFalse: [ (self | |
openCamera: camNum | |
width: 640 | |
height: 480) | |
ifNil: [ ^ self inform: 'no camera' ] ]. | |
self waitForCameraStart: camNum. | |
(self frameExtent: camNum) x = 0 | |
ifTrue: [ ^ self inform: 'no camera' ]. | |
f := Form extent: 640 @ 480 depth: 32. | |
100 | |
timesRepeat: [ n := CameraPlugin | |
getFrameForCamera: camNum | |
into: f bits ]. | |
CameraPlugin closeCamera: camNum. | |
^ f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment