2013-10-31 95 views
0

我的Java開發人員。我的目標是使用javaCV檢測圖像的關鍵點--javaCV --EXCEPTION_ACCESS_VIOLATION

這是我的代碼來檢測圖像的關鍵點:

 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); 

但是當我運行這段代碼我得到了一個訪問衝突異常

 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] 

我看不到問題在哪裏?

+0

任何迴應嗎? – nawara

回答

0

我沒有使用Java CV,但在C++ OpenCV中,Keypoint是一個關鍵點的結構,而檢測器需要獲得一個關鍵點向量。 您必須在Java中使用std :: vector(在C++中使用)的模擬。陣列或類似的東西。

0

您的代碼適用於我;我已經改變了唯一的一點是:

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

檢查圖像路徑:

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); 
} 
}