Ask Your Question

abrykt's profile - activity

2013-09-10 08:28:02 -0600 asked a question Surf and masks

I am writing an application that should detect keypoints and compute descriptors for the SURF algorithm. The keypoints and descriptors for various regions in an image should be detected/computed at various stages in the program. For example, if an 100x100 image is processed, the keypoints/descriptors for the region at (0,0) with width 50 and height 100 should be detected at one point, and the region at (50,0) with width 50 and height 100 should be detected at another point.

To detect the keypoints, I use the mask parameter to input a mask which have non zero values in the region where the detection should occur.

 Mat mat = imread( "box.png", CV_LOAD_IMAGE_GRAYSCALE );

 SurfFeatureDetector detector;
 std::vector<KeyPoint> keypoints_for_roi_1, keypoints_for_roi_2;

 cv::Mat mask1 = cv::Mat::zeros(mat.size(), mat.type());
 cv::Rect roi1(0, 0, 50, 100);
 cv::Mat selected1(mask1, roi1);  // select a ROI
 selected1 = cv::Scalar(255, 255, 255);
 detector.detect(mat, keypoints_for_roi_1, mask1);

 cv::Mat mask2 = cv::Mat::zeros(mat.size(), mat.type());
 cv::Rect roi2(0, 50, 50, 100);
 cv::Mat selected2(mask2, roi2);  // select a ROI
 selected2 = cv::Scalar(255, 255, 255);
 detector.detect(mat, keypoints_for_roi_2, mask2);

To compute the descriptors I then pass the whole image along with the detected keypoints.

 SurfDescriptorExtractor extractor;
 Mat descriptors_roi_1, descriptors_roi_2;

 extractor.compute(mat, keypoints_for_roi_1, descriptors_roi_1);
 extractor.compute(mat, keypoints_for_roi_2, descriptors_roi_2);

To check my results, I then detect keypoints and compute descriptors for the same image like this:

Mat mat = imread( "box.png", CV_LOAD_IMAGE_GRAYSCALE );
SurfFeatureDetector detector;
std::vector<KeyPoint> keypoints;  
detector.detect(mat, keypoints);
SurfDescriptorExtractor extractor;
Mat descriptors;
extractor.compute(mat, keypoints, descriptors);

I then check so that the keypoints in keypoints_for_roi_1 and keypoints_for_roi_2 are present in kepoints, and they are. So the keypoints are detected correct.

But, when I check so that the descriptors in descriptors_roi_1 and descriptors_roi_2 are present in descriptors, then some of them are but some are not (I check by looping thru the descriptors matrix to find the row which matches)

Does anyone have any idea why the descriptors does not match when compared?

2013-08-05 05:42:40 -0600 received badge  Scholar (source)
2013-08-05 05:42:35 -0600 received badge  Supporter (source)
2013-08-05 05:42:22 -0600 commented answer Compiler errors on Arm

I booted the Beaglebone Blackfrom and mini Sd-card with BeageBone Black Ubuntu Precise 12.04.2 LTS from this page http://www.armhf.com/index.php/download/. I then followed the same pages instruction on how to resize the card to get more space. I the used the 2.4.6 release version of OpenCv and recompiled it with gcc version 4.6. The compiler errrors described above is gone. Great!

2013-08-04 14:32:04 -0600 commented answer Compiler errors on Arm

Im a using the pre-installed verison on the beaglebone black, it is version 2.4.2. I will try the compiler you used and rebuild with those.

2013-08-02 08:26:04 -0600 commented answer Compiler errors on Arm

Hi Alexander, thanks for your comment. I should have mentioned the compiler used. The compiler used in beaglebone, which is running an Angstrom distribution, is arm-angstrom-linux-gnueabi-g++ I am cross-compling with this compiler from my desktop, and I also tried compiling directly on the beaglebone, but the errors are the same. OpenCv comes pre-installed on the beaglebone, so it would be strange if it did not work with the default compiler, or?

Do you have any experience using arm-angstrom-linux-gnueabi-g++ with OpenCv?

Maybe I should try gcc-arm-linux-gnueabi instead.

2013-08-01 18:50:38 -0600 received badge  Student (source)
2013-08-01 18:18:15 -0600 received badge  Editor (source)
2013-08-01 18:09:52 -0600 asked a question Compiler errors on Arm

When compiling on ubuntu 12.04 desktop with gcc 4.6 things works fine. When compiling on a beaglebone with an arm processor and arm-angstrom-linux-gnueabi-g++, the following compilation errors appear.

/usr/include/opencv2/core/core.hpp:443:23: error: statement-expressions are not allowed outside functions nor in template-argument lists
/usr/include/opencv2/core/core.hpp:443:35: error: template argument 2 is invalid

and

/usr/include/opencv2/core/operations.hpp: In static member function 'static cv::Matx<_Tp, m, n> cv::Matx<_Tp, m, n>::diag(const diag_type&)':
/usr/include/opencv2/core/operations.hpp:367:24: error: 'd' cannot be used as a function
/usr/include/opencv2/core/operations.hpp: In member function 'cv::Matx<_Tp, m, n>::diag_type cv::Matx<_Tp, m, n>::diag() const':
/usr/include/opencv2/core/operations.hpp:443:11: error: request for member 'val' in 'd', which is of non-class type 'cv::Matx<_Tp, m, n>::diag_type {aka int}'

There is no object named d with a member val, no object named d at all.

Any help or pointers is very appreciated!

(If you would like to try to build the project, just message me and I will give you permissions to do a checkout)