Eliot Miranda uploaded a new version of EToys to project The Trunk:
http://source.squeak.org/trunk/EToys-eem.402.mcz==================== Summary ====================
Name: EToys-eem.402
Author: eem
Time: 27 September 2020, 5:43:02.068038 pm
UUID: bbda2475-d7bb-4381-b306-0eab22b9ddad
Ancestors: EToys-eem.401
CameraInterface: document camera:getParam:. Provide a utility for evaluating a block with grabbed frames.
=============== Diff against EToys-eem.401 ===============
Item was added:
+ ----- Method: CameraInterface class>>camera:framesDo:while: (in category 'utilities') -----
+ camera: cameraNum framesDo: aBlock while: whileBlock
+ "Evaluate aBlock every time a frame becomes available. Answer a tuple of frames per second and number of 16ms delays per second.
+ Be destructive; use only one bitmap, overwriting its contents with each successive frame.
+ It is the sender's responsibility to open and close the camera."
+ | form bitmap delay start duration frameCount delayCount |
+ form := Form
+ extent: (self frameExtent: cameraNum)
+ depth: 32.
+ bitmap := form bits.
+ delay := Delay forMilliseconds: (1000 / 60) asInteger. "60 fps is fast"
+ start := Time utcMicrosecondClock.
+ frameCount := delayCount := 0.
+ [[(self camera: cameraNum getParam: 1) <= 0] whileTrue:
+ [delay wait. delayCount := delayCount + 1].
+ self getFrameForCamera: cameraNum into: bitmap.
+ frameCount := frameCount + 1.
+ aBlock value: form.
+ whileBlock value] whileTrue.
+ ^{ frameCount * 1.0e6 / (duration := Time utcMicrosecondClock - start).
+ delayCount * 1.0e6 / duration }
+
+ "| cameraNum |
+ self openCamera: (cameraNum := 1) width: 640 height: 480.
+ self waitForCameraStart: cameraNum.
+ [self camera: cameraNum framesDo: [:bitmap| bitmap display] while: [Sensor noButtonPressed]] ensure:
+ [self closeCamera: cameraNum]"!
Item was changed:
----- Method: CameraInterface class>>camera:getParam: (in category 'camera ops') -----
camera: cameraNum getParam: paramNum
+ "Answer the given parameter for the given camera.
+ param 1 is the frame count, the number of frames grabbed since the last send of getFrameForCamera:into:
+ param 2 is the size of the bitmap in bytes required for an image"
- "Answer the given parameter for the given camera."
+ <primitive: 'primGetParam' module: 'CameraPlugin' error: ec>
+ ^nil
- <primitive: 'primGetParam' module: 'CameraPlugin'>
- ^ nil
!