[**SOS**] LIBUSB_ERROR_TIMEOUT -7 during multi-thread multiple Kinect v2 implementation

195 views
Skip to first unread message

edwinz@CG

unread,
Nov 3, 2015, 3:23:00 PM11/3/15
to OpenKinect
Hey guys,

I am trying to use windows multi-thread to make 4 Kinect v2 run simultaneously. But here I meet some problem with LIBUSB_TIMEOUT ERROR -7.

 














I am using multithread to start devices at the same time, but it seems libfreenect2 doesn't recognize the right serial number.  Detailed log shown below:
[Freenect2Impl] enumerating devices...
[Freenect2Impl] 15 usb devices connected
[Freenect2Impl] found valid Kinect v2 @2:19 with serial 008427750247
[Freenect2Impl] found valid Kinect v2 @2:20 with serial 501778742542
[Freenect2Impl] found 2 devices
[Freenect2DeviceImpl] opening...
[Freenect2DeviceImpl] opened
[Freenect2Impl] enumerating devices...
[Freenect2Impl] 15 usb devices connected
[Freenect2Impl] found valid Kinect v2 @2:19 with serial 008427750247
[Freenect2Impl] found valid Kinect v2 @2:20 with serial 501778742542
[Freenect2Impl] found 2 devices
[Freenect2DeviceImpl] opening...
[Freenect2DeviceImpl] opened
Fi[nFdr eFeinresctt 2KDienveiccte
Impl] starting...
[Freenect2DeviceImpl] ReadData0x14 response
92 bytes of raw data
0x0000:  00 00 15 00 00 00 00 00 01 00 00 00 43 c1 1f 41    2e2e2e2e2e2e2e2e2e2e
2e2e432e2e41
0x0010:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    2e2e2e2e2e2e2e2e2e2e
2e2e2e2e2e2e
0x0020:  0a 21 33 55 ef 00 17 40 00 08 00 00 10 00 00 00    2e2133552e2e2e402e2e
2e2e2e2e2e2e
0x0030:  00 01 00 00 00 10 00 00 00 00 80 00 01 00 00 00    2e2e2e2e2e2e2e2e2e2e
802e2e2e2e2e
0x0040:  31 33 00 00 00 06 0e 13 47 4b 4b 30 31 38 2e 31    31332e2e2e2e2e2e474b
4b3031382e31
0x0050:  58 00 00 00 00 00 00 00 07 00 00 00                582e2e2e2e2e2e2e2e2e
2e2e

[Freenect2DeviceImpl] ReadStatus0x090000 response
4 bytes of raw data
0x0000:  7f 26 00 00                                        7f262e2e

[Freenect2DeviceImpl] ReadStatus0x090000 response
4 bytes of raw data
0x0000:  7f 26 00 00                                        7f262e2e

[Freenect2DeviceImpl] enabling usb transfer submission...
[Freenect2DeviceImpl] submitting usb transfers...
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TurboJpegRgbPacketProcessor::doProcess] Failed to decompress rgb image! TurboJP
EG error: 'Not a JPEG file: starts with 0x9c 0xa8'
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[TransferPool::submit] failed to submit transfer
[Freenect2DeviceImpl] started
[RgbPacketStreamParser::handleNewData] skipping rgb packet!
[RgbPacketStreamParser::handleNewData] skipping rgb packet!
Fin[dF rSeeecnoencdt 2KDienveiccte
ISmtprla]t  sutsairntgi nTgh.r.e.a
ds
[CommandTransaction::send] bulk transfer failed! libusb error -7: LIBUSB_ERROR_T
IMEOUT
[CommandTransaction::send] sent number of bytes differs from expected number! ex
pected: 20 got: 0
[TurboJpegRgbPacketProcessor] avg. time: 19.3446ms -> ~51.6941Hz
[CommandTransaction::send] bulk transfer failed! libusb error -7: LIBUSB_ERROR_T
IMEOUT
[CommandTransaction::send] sent number of bytes differs from expected number! ex
pected: 20 got: 0
[Freenect2DeviceImpl] ReadData0x14 response
0 bytes of raw data

[CommandTransaction::send] bulk transfer failed! libusb error -7: LIBUSB_ERROR_T
IMEOUT
[CommandTransaction::send] sent number of bytes differs from expected number! ex
pected: 24 got: 0
[Freenect2DeviceImpl] serial number reported by libusb 501778742542 differs from
 serial number 0?in device protocol!
[CommandTransaction::send] bulk transfer failed! libusb error -7: LIBUSB_ERROR_T
IMEOUT
[CommandTransaction::send] sent number of bytes differs from expected number! ex
pected: 24 got: 0


Especially the red output mentioned that seems the two threads didn't get equal resource distribution...
Is there any way can solve this problem?

Here is the code I am using for multi-thread Kinect:


// set protonect won't be shutdown in current configuration
bool protonect_shutdown = false;

// Create 2 freenect instances
libfreenect2::Freenect2 freenect2_1;
libfreenect2::Freenect2 freenect2_2;
// NUI sensor port will automatic find the device based on interface number.
libfreenect2::Freenect2Device *dev_1 = freenect2_1.openDevice(0);
libfreenect2::Freenect2Device *dev_2 = freenect2_2.openDevice(1);
// Construct thread
// Pre-called functions
unsigned int __stdcall libfreenect2_1(PVOID pM);
unsigned int __stdcall libfreenect2_2(PVOID pM);

void sigint_handler(int s)
{
  protonect_shutdown = true;
}

int main(int argc, char *argv[])
{

// reset the singal won't be shut down
signal(SIGINT,sigint_handler);
protonect_shutdown = false;

// Create 2 threads, each for one Kinect2
HANDLE hThread[2];
// setup thread for each Kinect
// use _beginthreadx to allocate individual memory storage (_tiddata block) for each thread

hThread[0]=(HANDLE)_beginthreadex( // return the HANDLE of thread
NULL, // security
8192000, // stack_size "0" = default (1MB)
libfreenect2_1, // address of function
NULL, // arg list
0, // 0 indicates manipulate immediately 
NULL); // return thread ID, NULL means no return
std::cout << "Find First Kinect" << std::endl;

Sleep(5000);

hThread[1]=(HANDLE)_beginthreadex(
NULL,
0,
libfreenect2_2,
NULL,
0,
NULL);
std::cout << "Find Second Kinect" << std::endl;

std::cout << "Strat using Threads" << std::endl;
WaitForMultipleObjects(2, hThread, TRUE, INFINITE);  


CloseHandle(hThread[0]);
CloseHandle(hThread[1]);
return 0;
}

unsigned int __stdcall libfreenect2_1(PVOID pM)
{
// setup listener
libfreenect2::SyncMultiFrameListener listener1(libfreenect2::Frame::Color | libfreenect2::Frame::Ir | libfreenect2::Frame::Depth);
libfreenect2::FrameMap frames_1;

if(dev_1 == 0)
{
std::cout << "no device connected or failure opening the default one!" << std::endl;
return -1;
}

// RGB and DEPTH listener init
dev_1->setColorFrameListener(&listener1);
dev_1->setIrAndDepthFrameListener(&listener1);
dev_1->start();

//std::cout << "device serial: " << dev_1->getSerialNumber() << std::endl;
//std::cout << "device firmware: " << dev_1->getFirmwareVersion() << std::endl;

for (int i = 0; i < 120; i++ )
{
// listen to new frame comes
listener1.waitForNewFrame(frames_1);
// put correspondent data to correspondent categories
//libfreenect2::Frame *rgb1 = frames_1[libfreenect2::Frame::Color];
libfreenect2::Frame *ir1 = frames_1[libfreenect2::Frame::Ir];
libfreenect2::Frame *depth1 = frames_1[libfreenect2::Frame::Depth];

// Display
//cv::imshow("rgb1", cv::Mat(rgb1->height, rgb1->width, CV_8UC3, rgb1->data));
cv::imshow("ir1", cv::Mat(ir1->height, ir1->width, CV_32FC1, ir1->data) / 20000.0f);
cv::imshow("depth1", cv::Mat(depth1->height, depth1->width, CV_32FC1, depth1->data) / 4500.0f);

int key1 = cv::waitKey(1);

protonect_shutdown = protonect_shutdown || (key1 > 0 && ((key1 & 0xFF) == 27)); // shutdown on escape
// free space after display the data
listener1.release(frames_1);
}

dev_1->stop();
dev_1->close();

return 0;
}

unsigned int __stdcall libfreenect2_2(PVOID pM)
{
libfreenect2::SyncMultiFrameListener listener2(libfreenect2::Frame::Color | libfreenect2::Frame::Ir | libfreenect2::Frame::Depth);
libfreenect2::FrameMap frames2;

if(dev_2 == 0)
{
std::cout << "no device connected or failure opening the dev1 one!" << std::endl;
return -1;
}

dev_2->setColorFrameListener(&listener2);
dev_2->setIrAndDepthFrameListener(&listener2);
dev_2->start();

//std::cout << "device serial: " << dev_2->getSerialNumber() << std::endl;
//std::cout << "device firmware: " << dev_2->getFirmwareVersion() << std::endl;

while(!protonect_shutdown)
{
listener2.waitForNewFrame(frames2);

//libfreenect2::Frame *rgb2 = frames2[libfreenect2::Frame::Color];
libfreenect2::Frame *ir2 = frames2[libfreenect2::Frame::Ir];
libfreenect2::Frame *depth2 = frames2[libfreenect2::Frame::Depth];

//cv::imshow("rgb2", cv::Mat(rgb2->height, rgb2->width, CV_8UC3, rgb2->data));
cv::imshow("ir2", cv::Mat(ir2->height, ir2->width, CV_32FC1, ir2->data) / 20000.0f);
cv::imshow("depth2", cv::Mat(depth2->height, depth2->width, CV_32FC1, depth2->data) / 4500.0f);

int key2 = cv::waitKey(1);

protonect_shutdown = protonect_shutdown || (key2 > 0 && ((key2 & 0xFF) == 27)); // shutdown on escape
listener2.release(frames2);
}
dev_2->stop();
dev_2->close();

return 0;
}
Reply all
Reply to author
Forward
0 new messages