2016-04-27 1 views
0

Ich möchte Koordinaten von QueryVertices() finden aber NULL-Wert während der Ausführung erhalten.NULL-Wert in QueryVertices() erhalten - Intel Real Sense F200

-Code 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 

gibt es eine andere wat die Co-ordinates.any Hilfe würde geschätzt zu bekommen.

danke im voraus.

+4

Mögliches Duplikat von [Was ist eine Nullzeigerausnahme und wie behebe ich sie?] (Http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how -do-i-fix-it) – Seth

+0

Ja, ich weiß, was ist Null Pointer Exception ... Problem, dass ich hier bin, ist, dass ich "NULL" in Vertices Array bekomme ... – AmanS

+0

Lesen Sie etwas über Arrays, es wird Nehmen Sie 5 Minuten und Sie werden wahrscheinlich das Problem noch vor dem c herausfinden: Und denken Sie über die Bedeutung einer NPE :) – Seth

Antwort

1

Ihr Scheitelpunkt-Array sollte die Größe des Tiefenbildes und nicht das Farbbild haben, da Sie für jedes Pixel im Tiefenbild einen Scheitelpunkt erhalten. Verwenden Sie stattdessen PXCMPoint3DF32[] vertices = new PXCMPoint3DF32[dWidth * dHeight];.

+0

Hi @ jb455 danke für deine Antwort ... i cha nged 'PXCMPoint3DF32 [] Vertices = new PXCMPoint3DF32 [cWidth * cHeight]; 'to' PXCMPoint3DF32 [] Vertices = new PXCMPoint3DF32 [dWidth * dHeight]; '... ich bekomme immernoch null Werte im Vertices-Array ... – AmanS

+0

Hm, alles, was Sie getan haben, ist das selbe wie in C#, was funktioniert ... Eine andere Möglichkeit, die Scheitelpunkte zu erhalten, ist [Projektion. ProjectColorToCamera] (https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?projectcolortocamera_pxcprojection.html), vielleicht versuchen Sie sich das anzuschauen? Es ist ein wenig peinlich, obwohl Sie die Tiefenwerte aus irgendeinem Grund zuerst den Farbpunkten zuordnen müssen. – jb455