
CHAPTER 15. MOTION DETECTOR
109
15.1
Technical Approach
NI Vision Assistant Script
The vision script merely needs to extract the luminance image from the color
webcam image because the optical flow VIs are not available in Vision Assistant;
see
for details.
Optical Flow VIs
The LabVIEW
IMAQ Optical Flow (HS)
VI computes the optical flow (velocity
flow) from two successive grayscale image frames using the Horn and Schunck
algorithm. Optical flow is a vector field, therefore the VI calculates two single-
precision floating point images (
[SGL]
) in either Cartesian or polar form. The
two images are generically called
Velocity Component 1
and
Velocity Compo-
nent 2
, and contain the
X
and
Y
vector components with “Cartesian” velocity
representation selected and the magnitude and phase with “Polar” represen-
tation selected. The VI includes additional inputs such as stopping criteria,
smoothing parameter, and the option to use the previously-calculated output
as a starting point for the new calculation.
The
IMAQ Overlay Motion Vectors
VI accepts the pair of velocity component
images generated above and generates a vector field overlay for a suitable image,
i.e., the original webcam image. This VI must use the same selected velocity
representation as that calculated by
IMAQ Optical Flow (HS)
, of course, and the
VI provides the ability to select the velocity threshold at which flow vectors are
drawn, the length of the arrows (scale) as well as their color, and a step size to
set the density of arrows.
LabVIEW Techniques
The following LabVIEW techniques are required for this project:
•
(qsm) initialize: Image Buffer
– Use the
IMAQ Create
VI to create image
buffers for the previous webcam frame (
[Grayscale (U8)]
), the two velocity
components (
[Grayscale (SGL)]
), and the detected motion (also
[Grayscale
(SGL)]
). Place these VIs in the
(qsm) initialize
state.
•
The usual “mode” and “action” buttons are not required for this project.
Instead of deleting the controls, simply right-click them in the block di-
(1:02)
(2:02)
Summary of Contents for NI myRIO
Page 1: ...Ed Doering NI myRIO Vision Essentials Guide...
Page 2: ......
Page 11: ...Part I Machine Vision Fundamentals...
Page 12: ......
Page 31: ...Part II Introductory Machine Vision Projects...
Page 32: ......
Page 38: ...32 CHAPTER 4 CAMERA SETUP...
Page 44: ...38 CHAPTER 5 STEREO VISION...
Page 61: ...Part III Machine Vision Application Projects...
Page 62: ......
Page 72: ...66 CHAPTER 8 COIN COUNTER...
Page 86: ...80 CHAPTER 10 KEYED OPTICAL LOCK...
Page 92: ...86 CHAPTER 11 DMM TEST STAND...
Page 134: ...128 CHAPTER 17 MARBLE SORTER...
Page 135: ...Part IV Appendices...
Page 136: ......
Page 143: ...B MXPandMSPConnectorDiagrams Figure B 1 MXP myRIO eXpansion Port connector diagram...
Page 144: ...138 APPENDIX B MXP AND MSP CONNECTOR DIAGRAMS Figure B 2 MSP miniSystem Port connector diagram...
Page 148: ...142 APPENDIX D BUILD A STAND ALONE APPLICATION...
Page 149: ...E MarbleSorterConstructionDetails To be continued...
Page 150: ...144 APPENDIX E MARBLE SORTER CONSTRUCTION DETAILS...