Skip to content

Instantly share code, notes, and snippets.

@gastonambrogi
Created August 1, 2018 23:17
Show Gist options
  • Save gastonambrogi/e9755a27dc72130d8724b08bc87cca67 to your computer and use it in GitHub Desktop.
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.).
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