The Trunk: MorphicExtras-eem.287.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: MorphicExtras-eem.287.mcz

commits-2
Eliot Miranda uploaded a new version of MorphicExtras to project The Trunk:
http://source.squeak.org/trunk/MorphicExtras-eem.287.mcz

==================== Summary ====================

Name: MorphicExtras-eem.287
Author: eem
Time: 12 April 2021, 11:02:21.284327 am
UUID: b74bcd77-a21f-4562-b441-5e2220720482
Ancestors: MorphicExtras-mt.286

Include the actual frame extent in the output of the CameraInterface test methods.

=============== Diff against MorphicExtras-mt.286 ===============

Item was changed:
  ----- Method: CameraInterface class>>interruptDrivenVideoTest: (in category 'test') -----
  interruptDrivenVideoTest: camNum
  "A quick test of video input. Displays video on the screen until the mouse is pressed.
  Answer nil if the interrupt-driven interface is unavailable."
  "self interruptDrivenVideoTest: 1"
  "self interruptDrivenVideoTest: 2"
  "[self interruptDrivenVideoTest: 2] fork.
   self interruptDrivenVideoTest: 1"
 
+ | semaphore height frameExtent |
- | semaphore height |
  height := 16.
  1 to: camNum - 1 do:
  [:camIndex| "N.B. the of an unopened camera is 0@0"
+ height := height + (self frameExtent: camIndex) y + 16].
+ (self cameraIsOpen: camNum) ifFalse:
+ [(self openCamera: camNum width: 352 height: 288) ifNil:
- height := height + (CameraInterface frameExtent: camIndex) y + 16].
- (CameraInterface cameraIsOpen: camNum) ifFalse:
- [(CameraInterface openCamera: camNum width: 352 height: 288) ifNil:
  [self inform: 'no camera'.
  ^nil]].
  semaphore := Semaphore new.
+ [self camera: camNum setSemaphore: (Smalltalk registerExternalObject: semaphore)]
- [CameraInterface camera: camNum setSemaphore: (Smalltalk registerExternalObject: semaphore)]
  on: Error
  do: [:err|
  Smalltalk unregisterExternalObject: semaphore.
  self inform: 'interrupt-driven camera interface unavailable: ', err messageText.
  ^nil].
  [| f n startTime frameCount msecs fps |
  [semaphore wait.
  "N.B. the frame extent may not be known until the delivery of the first frame.
   So we have to delay initialization."
   startTime ifNil:
+ [(frameExtent := self frameExtent: camNum) x = 0 ifTrue: [self inform: 'no camera'. ^nil].
+ f := Form extent: (self frameExtent: camNum) depth: 32.
- [(self frameExtent: camNum) x = 0 ifTrue: [self inform: 'no camera'. ^nil].
- f := Form extent: (CameraInterface frameExtent: camNum) depth: 32.
  frameCount := 0.
  startTime := Time millisecondClockValue].
   Sensor anyButtonPressed] whileFalse:
+ [n := self getFrameForCamera: camNum into: f bits.
- [n := CameraInterface getFrameForCamera: camNum into: f bits.
  n > 0 ifTrue:
  [frameCount := frameCount + 1.
  f displayAt: 16 @ height]].
  msecs := Time millisecondClockValue - startTime.
  fps := (frameCount * 1000) // msecs.
+ ^(self cameraName: camNum), ': ', frameExtent printString, ' ', frameCount printString, ' frames at ', fps printString, ' frames/sec']
- ^(CameraInterface cameraName: camNum), ': ', frameCount printString, ' frames at ', fps printString, ' frames/sec']
  ensure:
+ [self closeCamera: camNum.
- [CameraInterface closeCamera: camNum.
  Smalltalk unregisterExternalObject: semaphore.
  Sensor waitNoButton]!

Item was changed:
  ----- Method: CameraInterface class>>videoTest: (in category 'test') -----
  videoTest: camNum
  "A quick test of video input. Displays video on the screen until the mouse is pressed."
  "self videoTest: 1"
  "self videoTest: 2"
 
+ | frameExtent f n startTime frameCount msecs fps |
+ (self openCamera: camNum width: 320 height: 240) ifNil: [^ self inform: 'no camera'].
- | f n startTime frameCount msecs fps |
- (CameraInterface openCamera: camNum width: 320 height: 240) ifNil: [^ self inform: 'no camera'].
  self waitForCameraStart: camNum.
+ (frameExtent := self frameExtent: camNum) x = 0 ifTrue: [^ self inform: 'no camera'].
+ f := Form extent: (self frameExtent: camNum) depth: 32.
- (self frameExtent: camNum) x = 0 ifTrue: [^ self inform: 'no camera'].
- f := Form extent: (CameraInterface frameExtent: camNum) depth: 32.
  frameCount := 0.
  startTime := nil.
+ [Sensor anyButtonPressed] whileFalse:
+ [n := self getFrameForCamera: camNum into: f bits.
+ n > 0 ifTrue:
+ [startTime ifNil: [startTime := Time millisecondClockValue].
- [Sensor anyButtonPressed] whileFalse: [
- n := CameraInterface getFrameForCamera: camNum into: f bits.
- n > 0 ifTrue: [
- startTime ifNil: [startTime := Time millisecondClockValue].
  frameCount := frameCount + 1.
  f display]].
  Sensor waitNoButton.
  msecs := Time millisecondClockValue - startTime.
+ self closeCamera: camNum.
+ fps := frameCount * 1000 // msecs.
+ ^frameExtent printString, ' ', frameCount printString, ' frames at ', fps printString, ' frames/sec'!
- CameraInterface closeCamera: camNum.
- fps := (frameCount * 1000) // msecs.
- ^ frameCount printString, ' frames at ', fps printString, ' frames/sec'!