This example demonstrates ORB (Oriented FAST and Rotated BRIEF) feature detection using OpenVX with OpenCV extensions. The example processes images or live camera feeds to detect and extract keypoint features, which are useful for object recognition, image matching, and tracking applications.
ORB is a fast and efficient feature detector that combines:
- FAST (Features from Accelerated Segment Test) keypoint detection
- BRIEF (Binary Robust Independent Elementary Features) descriptor computation
- Orientation compensation for rotation invariance
- Parse command-line arguments for input source and image dimensions.
- Create OpenVX context and register log callback.
- Load OpenCV extension kernels into the OpenVX context.
- Create OpenVX graph for the feature detection pipeline.
- Allocate grayscale image for input and keypoints array for output.
- Configure ORB detector parameters (number of features, scale factor, pyramid levels, etc.).
- Create ORB detection node with specified parameters.
- Verify the graph to ensure all connections are valid.
- Process input (either from image file or live camera feed):
- Convert input to grayscale if needed
- Resize to target dimensions
- Copy input data to OpenVX image
- Execute graph to detect features
- Query the number of detected keypoints
- Map keypoints array to retrieve feature locations
- Visualize detected keypoints by drawing circles on the output image.
- Release all OpenVX resources (graph, array, image, context).
-
OpenVX Context Management: The OpenVX context manages all OpenVX resources and loaded extensions.
vxCreateContext(): Creates a new OpenVX context.vxRegisterLogCallback(): Registers a callback function for logging OpenVX messages.vxLoadKernels(): Loads extension kernel libraries (e.g.,vx_opencvfor OpenCV integration).vxReleaseContext(): Releases the context and all associated resources.
-
Graph Creation and Execution:
vxCreateGraph(): Creates a new graph within a context for defining the processing pipeline.vxVerifyGraph(): Verifies that the graph is valid and ready for execution.vxProcessGraph(): Executes the graph to perform feature detection.vxReleaseGraph(): Releases the graph object.
-
Image Objects:
vxCreateImage(): Creates an image object with specified dimensions and format (grayscale for ORB input).vxCopyImagePatch(): Copies image data between host memory and OpenVX image objects.vxReleaseImage(): Releases an image object.
-
Array Objects for Keypoints:
vxCreateArray(): Creates an array to store detected keypoints. Specifies element type (VX_TYPE_KEYPOINT) and capacity.vxQueryArray(): Queries array properties such as the number of items (VX_ARRAY_NUMITEMS).vxMapArrayRange(): Maps a range of array elements to host-accessible memory for reading keypoint data.vxUnmapArrayRange(): Unmaps a previously mapped array range.vxReleaseArray(): Releases an array object.
-
OpenCV Extension - ORB Detection:
vxExtCvNode_orbDetect(): Creates an ORB feature detection node with configurable parameters:n_features: Maximum number of features to detectscale_factor: Pyramid decimation ratio (typically 1.2)n_levels: Number of pyramid levelsedge_threshold: Size of border where features are not detectedfirst_level: Level of pyramid to start feature detectionwta_k: Number of points for computing BRIEF descriptor (2, 3, or 4)score_type: Scoring method (0 for HARRIS, 1 for FAST)patch_size: Size of patch used for descriptor computation
-
Keypoint Data Structure:
vx_keypoint_t: Structure containing keypoint information including x, y coordinates, strength, scale, orientation, and tracking status.
-
Key Enumerations and Constants:
VX_DF_IMAGE_U8: 8-bit unsigned grayscale image format.VX_TYPE_KEYPOINT: Data type identifier for keypoint structures.VX_ARRAY_NUMITEMS: Array attribute for querying the number of valid items.VX_SUCCESS: Status code indicating successful operation.VX_READ_ONLY: Access mode for read-only mapping.VX_MEMORY_TYPE_HOST: Memory type for host-accessible data.
-
Utility Functions (from
mivisionx_utils.hpp):ERROR_CHECK_STATUS(): Macro to check OpenVX status codes and exit on error.ERROR_CHECK_OBJECT(): Macro to check OpenVX object validity and exit on error.init_vx_rectangle(): Helper to initialize rectangle structures for image regions.init_vx_image_layout_gray(): Helper to initialize image layout for grayscale images.
vxCreateContextvxReleaseContextvxRegisterLogCallbackvxLoadKernelsvxCreateGraphvxVerifyGraphvxProcessGraphvxReleaseGraphvxCreateImagevxReleaseImagevxCopyImagePatchvxCreateArrayvxQueryArrayvxMapArrayRangevxUnmapArrayRangevxReleaseArrayvxReleaseNodevxGetStatus
vxExtCvNode_orbDetectvx_opencvkernel library
vx_contextvx_graphvx_imagevx_nodevx_arrayvx_keypoint_tvx_statusvx_rectangle_tvx_imagepatch_addressing_tvx_map_idvx_int32vx_uint8vx_uint32vx_float32vx_sizeVX_DF_IMAGE_U8VX_TYPE_KEYPOINTVX_ARRAY_NUMITEMSVX_SUCCESSVX_WRITE_ONLYVX_READ_ONLYVX_MEMORY_TYPE_HOST
cv::Matcv::VideoCapturecv::imreadcv::cvtColorcv::resizecv::circlecv::imshowcv::waitKeycv::Pointcv::Sizecv::ScalarCOLOR_RGB2GRAY