An error was reported during the process of performing orb feature point extraction: OpenCV Error: Assertion failed (!outImage.empty()) in drawKeypoints

When performing ORB point feature extraction: an error is reported

OpenCV Error: Assertion failed (!outImage.empty()) in drawKeypoints, file /home/ssf/Downloads/opencv-3.1.0/modules/features2d/src/draw.cpp, line 113
terminate called after throwing an instance of 'cv::Exception'
what():  /home/Downloads/opencv-3.1.0/modules/features2d/src/draw.cpp:113: error: (-215) !outImage.empty() in function drawKeypoints

Solution : The image is placed in the wrong location, placed in the same folder as the executable file:  ./fastFeatures 

Adjust the corresponding program code and store the location of the picture file again;

/*imwrite("../../result/out00.jpg",keyPointImage);*/; where ../.. returns to the upper two-level directory;

The adjustment code is: imwrite("out00.png",keyPointImage);

Mat srcImage = imread("img1.png");

 

The following are the parameter definitions of the query opencv function drawKeypoints used in the process of program code debugging :

opencv provides a function drawKeypoints to quickly draw feature points:

One parameter image: the original image, which can be a three-channel or single-channel image;

The second parameter keypoints: feature point vector, each element in the vector is a KeyPoint object, which contains various attribute information of the feature point;

The third parameter outImage: the canvas image drawn by the feature points, which can be the original image;

The fourth parameter color: the color information of the drawn feature points, the default drawn is random color;

The fifth parameter flags: the drawing mode of the feature points. In fact, the information that sets the feature points needs to be drawn, and those that do not need to be drawn, there are the following modes to choose:

DEFAULT: Only draw the coordinate points of the characteristic points, which are displayed as small dots on the image, and the center coordinates of each small dot are the coordinates of the characteristic point.

DRAW_OVER_OUTIMG: The function does not create the output image, but draws directly in the output image variable space. The output image variable itself is required to be initialized. Both size and type are initialized variables.
NOT_DRAW_SINGLE_POINTS: Single point feature points are not draw

DRAW_RICH_KEYPOINTS: When drawing feature points, the circles with directions are drawn. This method displays the coordinates, size, and direction of the image at the same time, which is the best drawing method to display the features.

drawKeypoints(srcImage,detectKeyPoint,keyPointImage,Scalar::all(-1),DrawMatchesFlags::DEFAULT);

fangzai bin wenjianjia yu kezhixing wenjian yiqi

 ./fastFeatures

In addition, when the program is running, you can check whether the version number of opencv in CmakeLists.txt is the same as the version number of the machine. You can specify the version number to avoid confusion:

CmakeLists.txt add:

find_package(OpenCV 3.3.1 REQUIRED)

 

 

 

Guess you like

Origin blog.csdn.net/neptune4751/article/details/108987876