4949// Useful macros for OpenVX error checking:
5050// ERROR_CHECK_STATUS - check status is VX_SUCCESS
5151// ERROR_CHECK_OBJECT - check if the object creation is successful
52- #define ERROR_CHECK_STATUS (status ) { \
52+ #define ERROR_CHECK_STATUS ( status ) { \
5353 vx_status status_ = (status); \
5454 if (status_ != VX_SUCCESS) { \
5555 printf (" ERROR: failed with status = (%d) at " __FILE__ " #%d\n " , status_, __LINE__); \
5656 exit (1 ); \
5757 } \
5858 }
5959
60- #define ERROR_CHECK_OBJECT (obj ) { \
60+ #define ERROR_CHECK_OBJECT ( obj ) { \
6161 vx_status status_ = vxGetStatus ((vx_reference)(obj)); \
6262 if (status_ != VX_SUCCESS) { \
6363 printf (" ERROR: failed with status = (%d) at " __FILE__ " #%d\n " , status_, __LINE__); \
@@ -601,7 +601,7 @@ int main( int argc, char * argv[] )
601601 vxChannelExtractNode ( graphHarris, harris_yuv_image, VX_CHANNEL_Y, harris_luma_image ),
602602 vxGaussianPyramidNode ( graphHarris, harris_luma_image, currentPyramid ),
603603 vxHarrisCornersNode ( graphHarris, harris_luma_image, strength_thresh, min_distance,
604- sensitivity, harris_gradient_size, harris_block_size, currentKeypoints, NULL )
604+ sensitivity, harris_gradient_size, harris_block_size, currentKeypoints, NULL )
605605 };
606606 for ( vx_size i = 0 ; i < sizeof ( nodesHarris ) / sizeof ( nodesHarris[0 ] ); i++ )
607607 {
@@ -629,9 +629,9 @@ int main( int argc, char * argv[] )
629629 vxChannelExtractNode ( graphTrack, opticalflow_yuv_image, VX_CHANNEL_Y, opticalflow_luma_image ),
630630 vxGaussianPyramidNode ( graphTrack, opticalflow_luma_image, currentPyramid ),
631631 userPickFeaturesNode ( graphTrack, previousKeypoints, previousPyramidLevel0, strength_thresh,
632- min_distance, sensitivity, harris_gradient_size, harris_block_size, featureKeypoints ),
632+ min_distance, sensitivity, harris_gradient_size, harris_block_size, featureKeypoints ),
633633 vxOpticalFlowPyrLKNode ( graphTrack, previousPyramid, currentPyramid, featureKeypoints, featureKeypoints,
634- currentKeypoints, lk_termination, epsilon, num_iterations, use_initial_estimate, lk_window_dimension )
634+ currentKeypoints, lk_termination, epsilon, num_iterations, use_initial_estimate, lk_window_dimension )
635635 };
636636 for ( vx_size i = 0 ; i < sizeof ( nodesTrack ) / sizeof ( nodesTrack[0 ] ); i++ )
637637 {
@@ -647,10 +647,6 @@ int main( int argc, char * argv[] )
647647 // Process the video sequence frame by frame until the end of sequence or aborted.
648648 for ( int frame_index = 0 ; !gui.AbortRequested (); frame_index++ )
649649 {
650- // //////
651- // local variable for checking the status of OpenVX API calls
652- vx_status status;
653-
654650 // //////
655651 // Copy the input RGB frame from OpenCV to OpenVX.
656652 // In order to do this, you need to use vxAccessImagePatch and vxCommitImagePatch APIs.
@@ -664,38 +660,32 @@ int main( int argc, char * argv[] )
664660 cv_rgb_image_layout.stride_x = 3 ;
665661 cv_rgb_image_layout.stride_y = gui.GetStride ();
666662 vx_uint8 * cv_rgb_image_buffer = gui.GetBuffer ();
667- status = vxAccessImagePatch ( input_rgb_image, &cv_rgb_image_region, 0 ,
668- &cv_rgb_image_layout, ( void ** )&cv_rgb_image_buffer, VX_WRITE_ONLY );
669- ERROR_CHECK_STATUS ( status );
670- status = vxCommitImagePatch ( input_rgb_image, &cv_rgb_image_region, 0 ,
671- &cv_rgb_image_layout, cv_rgb_image_buffer );
672- ERROR_CHECK_STATUS ( status );
663+ ERROR_CHECK_STATUS ( vxAccessImagePatch ( input_rgb_image, &cv_rgb_image_region, 0 ,
664+ &cv_rgb_image_layout, ( void ** )&cv_rgb_image_buffer, VX_WRITE_ONLY ) );
665+ ERROR_CHECK_STATUS ( vxCommitImagePatch ( input_rgb_image, &cv_rgb_image_region, 0 ,
666+ &cv_rgb_image_layout, cv_rgb_image_buffer ) );
673667
674668 // //////********
675669 // Now that input RGB image is ready, just run a graph.
676670 // Run Harris at the beginning to initialize the previous keypoints.
677- status = vxProcessGraph ( frame_index == 0 ? graphHarris : graphTrack );
678- ERROR_CHECK_STATUS ( status );
671+ ERROR_CHECK_STATUS ( vxProcessGraph ( frame_index == 0 ? graphHarris : graphTrack ) );
679672
680673 // //////********
681674 // To mark the keypoints in display, you need to access the output
682675 // keypoint array and draw each item on the output window using gui.DrawArrow().
683676 vx_size num_corners = 0 , num_tracking = 0 ;
684677 currentKeypoints = ( vx_array )vxGetReferenceFromDelay ( keypointsDelay, 0 );
685678 ERROR_CHECK_OBJECT ( currentKeypoints );
686- status = vxQueryArray ( featureKeypoints,
687- VX_ARRAY_ATTRIBUTE_NUMITEMS, &num_corners, sizeof ( num_corners ) );
688- ERROR_CHECK_STATUS ( status );
679+ ERROR_CHECK_STATUS ( vxQueryArray ( featureKeypoints,
680+ VX_ARRAY_ATTRIBUTE_NUMITEMS, &num_corners, sizeof ( num_corners ) ) );
689681 if ( num_corners > 0 )
690682 {
691683 vx_size kp_old_stride, kp_new_stride;
692684 vx_keypoint_t * kp_old_buf = NULL , * kp_new_buf = NULL ;
693- status = vxAccessArrayRange ( featureKeypoints, 0 , num_corners,
694- &kp_old_stride, ( void ** ) &kp_old_buf, VX_READ_ONLY );
695- ERROR_CHECK_STATUS ( status );
696- status = vxAccessArrayRange ( currentKeypoints, 0 , num_corners,
697- &kp_new_stride, ( void ** ) &kp_new_buf, VX_READ_ONLY );
698- ERROR_CHECK_STATUS ( status );
685+ ERROR_CHECK_STATUS ( vxAccessArrayRange ( featureKeypoints, 0 , num_corners,
686+ &kp_old_stride, ( void ** ) &kp_old_buf, VX_READ_ONLY ) );
687+ ERROR_CHECK_STATUS ( vxAccessArrayRange ( currentKeypoints, 0 , num_corners,
688+ &kp_new_stride, ( void ** ) &kp_new_buf, VX_READ_ONLY ) );
699689 for ( vx_size i = 0 ; i < num_corners; i++ )
700690 {
701691 vx_keypoint_t * kp_old = &vxArrayItem ( vx_keypoint_t , kp_old_buf, i, kp_old_stride );
@@ -706,10 +696,8 @@ int main( int argc, char * argv[] )
706696 gui.DrawArrow ( kp_old->x , kp_old->y , kp_new->x , kp_new->y );
707697 }
708698 }
709- status = vxCommitArrayRange ( featureKeypoints, 0 , num_corners, kp_old_buf );
710- ERROR_CHECK_STATUS ( status );
711- status = vxCommitArrayRange ( currentKeypoints, 0 , num_corners, kp_new_buf );
712- ERROR_CHECK_STATUS ( status );
699+ ERROR_CHECK_STATUS ( vxCommitArrayRange ( featureKeypoints, 0 , num_corners, kp_old_buf ) );
700+ ERROR_CHECK_STATUS ( vxCommitArrayRange ( currentKeypoints, 0 , num_corners, kp_new_buf ) );
713701 }
714702
715703 // //////********
@@ -744,7 +732,7 @@ int main( int argc, char * argv[] )
744732 " Harris %9d %7.3f %7.3f\n "
745733 " Track %9d %7.3f %7.3f\n " ,
746734 ( int )perfHarris.num , ( float )perfHarris.avg * 1e-6f , ( float )perfHarris.min * 1e-6f ,
747- ( int )perfTrack.num , ( float )perfTrack.avg * 1e-6f , ( float )perfTrack.min * 1e-6f );
735+ ( int )perfTrack.num , ( float )perfTrack.avg * 1e-6f , ( float )perfTrack.min * 1e-6f );
748736
749737 // //////********
750738 // Release all the OpenVX objects created in this exercise, and make the context as the last one to release.
0 commit comments