
114
CHAPTER 16. AUTO-PAN CAMERA
plane (refer to
but select hue instead of luminance,
of course), dual-threshold the hue image with user-defined low and high values
to select the pixels that match the defined hue (see
), remove noise pixels and other small objects (see
), find the energy center (centroid) of the image (see
), and report the number of detected objects (see
this step serves
only
to count the particles, therefore choose any single
measurement such as “Center of Mass X”).
Select the thresholding
Range
control and the
Centroid
and
Number
of Particles
indicators when you import this script into the Vision Assis-
tant Express VI. The hue thresholds will likely need adjustment occasionally as
lighting conditions change.
Camera Position Controller
The webcam is mounted to a servomotor as shown in Figure 16.3 on the facing
page; the servomotor pans the camera to any desired angle over a 180
◦
range.
The camera position controller can be completely implemented in the
(myRIO) update ports
state. In this state the tracked object’s measured X-
position from the vision script is converted into a value between 0 and 100, and
the
PID Advanced
VI compares this measured position to the desired position to
generate a command signal to the servo via the
PWM
Express VI; the command
signal manipulates the servomotor to minimize the difference (error signal)
between the measured position and the desired position.
T
IP
:
Use the “Quick Drop” shortcut (Ctrl + space bar) to look up and
place a LabVIEW element by name. See Appendix C on page 139 for more
LabVIEW tips.
Measured
X
-position
The vision script produces two outputs, the tracked object’s position and the
number of objects detected. Enclose the PID and PWM VIs and associated code
in a Boolean case structure so that these run
only
when a single tracked object
is detected. This way the camera will remain stationary when the tracked object
disappears and will also not be distracted by competing features.
(1:02)
(1:56)
(1:09)
(0:57)
(1:44)
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...