2016-04-27 3 views
0

QueryVertices()の座標を検索しますが、実行中にnull値を取得したいとします。QueryVertices()でヌル値を取得する - Intel Real Sense F200

コードSnippet-

public class CameraViewer2 
{  
    static int cWidth = 640; //Color image width 
    static int cHeight = 480; //Color image height 
    static int dWidth, dHeight; //depth image width and height 
    static boolean exit = false;//flag 

public static void main(String s[]) 
{ 

    PXCMSenseManager senseMgr = PXCMSenseManager.CreateInstance();  //Create a session manager instance 
    pxcmStatus sts = senseMgr.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, cWidth, cHeight); //STREAM_TYPE_COLOR The color stream. 
    sts = senseMgr.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH,cWidth,cHeight); //STREAM_TYPE_DEPTH The depth stream. 
    sts = senseMgr.Init(); //initialize the Manager 

    //getting the profile data 
    PXCMCapture.Device device = senseMgr.QueryCaptureManager().QueryDevice(); 
    PXCMCapture.Device.StreamProfileSet profiles = new PXCMCapture.Device.StreamProfileSet(); 
    device.QueryStreamProfileSet(profiles); 

    dWidth = profiles.depth.imageInfo.width; 
    dHeight = profiles.depth.imageInfo.height; 

    Listener listener = new Listener(); 

    if (sts == pxcmStatus.PXCM_STATUS_NO_ERROR) 
    { 
     while (listener.exit == false) 
     { 
      sts = senseMgr.AcquireFrame(true); //Wait until a new frame is available and lock it for processing. 
      if (sts == pxcmStatus.PXCM_STATUS_NO_ERROR) 
      { 
       PXCMCapture.Sample sample = senseMgr.QuerySample(); // retrieve the color and depth samples aligned 
       if (sample.color != null) 
       { 
        PXCMImage depth= sample.depth; 
        PXCMImage color= sample.color; 
        PXCMProjection projection=device.CreateProjection();// Create the PXCMProjection instance.    
        PXCMImage mappedColorImage=projection.CreateColorImageMappedToDepth(depth, color); 

        PXCMPoint3DF32[] vertices = new PXCMPoint3DF32[cWidth * cHeight]; 
        System.out.println(projection.QueryVertices(depth, vertices)); //getting in console- PXCM_STATUS_NO_ERROR 

いただければ幸い共同ordinates.anyの助けを得るために、他のワットがあります。

ありがとうございます。

+4

[Null Pointer Exceptionとは何ですか?それを修正するにはどうすればいいですか?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how -do-i-fix-it) – Seth

+0

はい私はヌルポインタの例外が何であるか知っています...私がここで直面している問題は、頂点配列に "NULL"が入っていることです... – AmanS

+0

配列について読んでみましょうあなたに5分かかると、おそらくその前にその問題を把握するだろう:NPEの意味について考える: – Seth

答えて

1

頂点配列は、奥行き画像の各ピクセルの頂点を取得するので、カラー画像ではなく、奥行き画像のサイズにする必要があります。代わりにPXCMPoint3DF32[] vertices = new PXCMPoint3DF32[dWidth * dHeight];を使用してください。

+0

こんにちは@ jb455、 nged 'PXCMPoint3DF32 []頂点=新しいPXCMPoint3DF32 [cWidth * cHeight]; 'to' PXCMPoint3DF32 []頂点=新しいPXCMPoint3DF32 [dWidth * dHeight]; '...まだ頂点配列のヌル値を取得しています... – AmanS

+0

ええと、あなたがしたことは、C#と同じです。頂点を取得する別の方法は、[投影法]を使用しています。 ProjectColorToCamera](https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?projectcolortocamera_pxcprojection.html)、おそらくそれを見てみてください。何らかの理由で深度の値を最初にカラーポイントにマップする必要があるので、少し厄介です。 – jb455

関連する問題