Page 222 - PDA Robotics Using Your Personal Digital Assistant to Control Your Robot
P. 222

PDA 10  5/27/03  8:51 AM  Page 198
                               //                    PDA Robotics
                               // Activate the motion detection
                               //
                               CAPTUREPARMS cap_params;
                               long struct_size = sizeof( CAPTUREPARMS );
                               capCaptureGetSetup( h_capwin, &cap_params, struct_size);
                               cap_params.fLimitEnabled = FALSE;
                               cap_params.fAbortLeftMouse = FALSE;
                               cap_params.fAbortRightMouse = FALSE;
                               cap_params.wTimeLimit = 3600; // reset after 60 second test
                               cap_params.fYield = TRUE;
                               //
                               // Throw away the audio for now ... will use same algorithm
                               // for sound detection
                               //

                               cap_params.fCaptureAudio = FALSE;
                               cap_params.wNumVideoRequested = 1;
                               capCaptureSetSetup( h_capwin, &cap_params, struct_size);

                               //
                               // Set the callback to which the vidoe will be stramed
                               //

                               BOOL ret = capSetCallbackOnVideoStream( h_capwin, (LPVOID) stream_callback );
                               capCaptureSequenceNoFile( h_capwin );

                             }else{
                               //
                               // Unchecked the motion detection
                               //
                               m_radar_stat.SetWindowText("Motion Sense : OFF");
                               capCaptureAbort(h_capwin);
                               m_stretch_video.EnableWindow(TRUE);
                             }
                          }

                          The video frames will be sent to this callback function where we will
                          compare the last video frame sent to the current

                          LRESULT stream_callback(HWND hWnd, LPVIDEOHDR lpVHdr)
                          {
                             static initialized;
                             static DWORD frame_same_total;
                             static last_frame_bytes;
                          198
   217   218   219   220   221   222   223   224   225   226   227