detecting image keypoints --javaCV --EXCEPTION_ACCESS_VIOLATION

血红的双手。 提交于 2019-12-25 11:58:42

问题


I'm java developer .My goal is to detect image keypoints using javaCV

this is my code :

      final CvMat image1 = cvLoadImageM("im1.png" , 0);

      final CvMat image2 = cvLoadImageM("im2.png", 0);

      SIFT  sift = new SIFT();

  FeatureDetector featureDetector =sift.getFeatureDetector();


      KeyPoint keypoint1 = new KeyPoint();

  KeyPoint keypoint2 = new KeyPoint() ;

  featureDetector.detect(image1, keypoint1 , null);


      featureDetector.detect(image2,keypoint2, null);

but when I run this code I got an access violation exception

     A fatal error has been detected by the Java Runtime Environment:

     EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7795e3be, pid=128, tid=2348


     JRE version: Java(TM) SE Runtime Environment (7.0_45-b18) (build 1.7.0_45-b18)

     Java VM: Java HotSpot(TM) Client VM (24.45-b08 mixed mode, sharing windows-x86 )

     Problematic frame:

     C  [ntdll.dll+0x2e3be]

I can't see where is the problem ?


回答1:


I haven`t work with Java CV, but in C++ OpenCV, Keypoint is structure for ONE keypoint, while detector needs to get a vector of keypoints. You have to use analogue of std::vector(used in C++) in Java., e.g. Array or something similar.




回答2:


Your code worked for me; the only thing I have changed is:

final CvMat image1 = cvLoadImageM("C:/temp/316.jpg" , 0);
final CvMat image2 = cvLoadImageM("C:/temp/330.jpg", 0);

Check your image path:

import com.googlecode.javacv.cpp.opencv_core.CvMat;
import com.googlecode.javacv.cpp.opencv_features2d.FeatureDetector;
import com.googlecode.javacv.cpp.opencv_features2d.KeyPoint;
import com.googlecode.javacv.cpp.opencv_nonfree.SIFT;

import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImageM;
public class any {
public static void main(String args[])
{
final CvMat image1 = cvLoadImageM("C:/temp/316.jpg" , 0);

    final CvMat image2 = cvLoadImageM("C:/temp/330.jpg", 0);
    if(image1==null)
    System.out.println("image is null");
if(image2==null)
    System.out.println("image is null");

SIFT  sift = new SIFT();
FeatureDetector featureDetector =sift.getFeatureDetector();
KeyPoint keypoint1 = new KeyPoint();
KeyPoint keypoint2 = new KeyPoint() ;
featureDetector.detect(image1, keypoint1 , null);
featureDetector.detect(image2,keypoint2, null);
System.out.println(keypoint1);
}
}


来源:https://stackoverflow.com/questions/19716292/detecting-image-keypoints-javacv-exception-access-violation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!