Quote:
Originally Posted by Greg McKaskle
Just so there is no misunderstanding, the vision libraries that LabVIEW uses are equally accessible from C/C++. The NI product for C development is called LabWindows CVI, so the vision documentation with the CVI suffix is all about the C/C++ entry points.
|
So I've spent the morning looking around nivision.h, the "NI Vision for LabWindows/CVI Function Reference Help", and the old ellipsis tracking code to figure out tracking rectangles in C++. Here's a snippet of [entirely untested as I don't currently have access to a cRio] code.
Code:
void Camera::FindRectangles() {
HSLImage *rawImage = camera.GetImage();
MonoImage *monoImage = rawImage->GetLuminancePlane();
Image *image = monoImage->GetImaqImage();
workingImageWidth = monoImage->GetWidth();
workingImageHeight = monoImage->GetHeight();
delete monoImage;
delete rawImage;
RectangleDescriptor *rectangleDescriptor = new RectangleDescriptor;
rectangleDescriptor->minWidth = 0;
rectangleDescriptor->minHeight = 0;
rectangleDescriptor->maxWidth = workingImageWidth;
rectangleDescriptor->maxHeight = workingImageHeight;
int numCurrentMatches;
RectangleMatch *temp;
temp = imaqDetectRectangles(image,
rectangleDescriptor,
NULL, // Default curve options as per manual.
NULL, // Default shape detection options.
NULL, // (ROI) Whole image should be searched.
&numCurrentMatches);
matches->erase(matches->begin(), matches->end());
matches = new vector<RectangleMatch>;
for (int i = 0; i < numCurrentMatches; i++)
matches->push_back(temp[i]);
imaqDispose(temp);
}
EDIT: CVI manual located at C:\Program Files (x86)\National Instruments\Vision\Documentation\VDM_CVI_User_Manu al.pdf