【问题标题】:Getting null value in QueryVertices()- Intel Real Sense F200在 Query Vertices() 中获取空值 - Intel Realsense F200
【发布时间】:2016-04-27 08:49:27
【问题描述】:

我想从 QueryVertices() 中查找坐标,但在执行时得到空值。

代码片段-

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

还有其他方法可以获取坐标吗?任何帮助将不胜感激。

提前致谢。

【问题讨论】:

  • 是的,我知道什么是空指针异常......我在这里面临的问题是我在顶点数组中得到“NULL”......
  • 阅读一些有关数组的内容,这将花费您 5 分钟,您可能会在此之前弄清楚问题:并考虑 NPE 的含义 :)
  • 我对数组和 NPE 有很好的理解...我猜这里的问题是特定于英特尔 realsense api...也许我没有遵循正确的方法...上面的代码正在工作正确并且没有给出任何异常/错误,否则 queryvertices 方法也返回 PXCM_STATUS_NO_ERROR

标签: java realsense


【解决方案1】:

您的顶点数组应该是深度图像的大小,而不是彩色图像的大小,因为您会为深度图像中的每个像素获取一个顶点。所以请改用PXCMPoint3DF32[] vertices = new PXCMPoint3DF32[dWidth * dHeight];

【讨论】:

  • 嗨 @jb455 感谢您的回复...我更改了 ' PXCMPoint3DF32[] vertices = new PXCMPoint3DF32[cWidth * cHeight]; ' to ' PXCMPoint3DF32[] 顶点 = new PXCMPoint3DF32[dWidth * dHeight]; '......我仍然在顶点数组中得到空值......
  • 嗯,你所做的一切都与我在 C# 中所做的一样,这很有效...获取顶点的另一种方法是使用projection.ProjectColorToCamera,也许试试看?这有点尴尬,因为出于某种原因您必须首先将深度值映射到颜色点。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-10-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-06
  • 1970-01-01
  • 2023-03-12
相关资源
最近更新 更多