OpenKinect / libfreenect2

Open source drivers for the Kinect for Windows v2 device
2.06k stars 746 forks source link

When device started,the infrared lamp donot light #823

Open Nancy302 opened 7 years ago

Nancy302 commented 7 years ago

Overview Description:

  1. When the device started,the infrared lamp donot light. This problem happend accidentally. I wonder is there something wrong with the usb ports. 2.Another problem is with the following code, there is 10M memory leak when initialized and closed the device one time, is there any bug in my code.

Version, Platform, and Hardware Bug Found:

  1. git log -1 --oneline
  2. uname -a
  3. lsusb -t
  4. lspci -nn

Steps to Reproduce:

Actual Results:

Expected Results:

Reproducibility:

Additional Information:

/// Initializes the default Kinect sensor
bool CBodyTracking::InitializeKinectSensors()
{
        //KinectCount=2
    if (freenect2.enumerateDevices() < KinectCount)
    {
        std::cout << "no enough device connected!" << std::endl;
        return false;
    }

    for (int i = 0; i < KinectCount; i++)
    {
        //find device1----------------------------------------------------- 
        serial[i] = "";
        serial[i] = freenect2.getDeviceSerialNumber(i);
        if (serial[i] == "")
        {
            std::cout << "failure to get the serials! " << i << std::endl;
            CloseKinectSensors();
            return false;
        }

        /*libfreenect2::PacketPipeline *pipeline = NULL;
        pipeline = new libfreenect2::OpenGLPacketPipeline();
        if (pipeline)
        devices[i] = freenect2.openDevice(serial[i], pipeline);
        else
        devices[i] = freenect2.openDevice(serial[i]);*/

        devices[i] = freenect2.openDevice(serial[i]);

        if (devices[i])
        {
            int types = 0;
            types |= libfreenect2::Frame::Color | libfreenect2::Frame::Ir | libfreenect2::Frame::Depth;
            listeners[i] = new libfreenect2::SyncMultiFrameListener(types);
            devices[i]->setColorFrameListener(listeners[i]);
            devices[i]->setIrAndDepthFrameListener(listeners[i]);

            if (!devices[i]->start())
            {
                std::cout << "failure start device!" << i << std::endl;
                CloseKinectSensors();
                return false;
            }
        }
        else
        {
            std::cout << "failure opening device" << i << std::endl;
            CloseKinectSensors();
            return false;
        }
        depthPars[i] = devices[i]->getIrCameraParams();
        colorPars[i] = devices[i]->getColorCameraParams();
        registrations[i] = new libfreenect2::Registration(depthPars[i], colorPars[i]);
    }
    return true;
}

void CBodyTracking::CloseKinectSensors()
{
    //! [stop]
    for (int i = 0; i < KinectCount; i++)
    {
        if (devices[i])
        {
            devices[i]->stop() ;
                        devices[i]->close();
            delete devices[i];
            devices[i] = NULL;
        }
        if (listeners[i])
        {
            delete listeners[i];
            listeners[i] = NULL;
        }
        if (registrations[i])
        {
            delete registrations[i];
            registrations[i] = NULL;
        }
    }
}
xlz commented 7 years ago

Please fill out the bug report template.