This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

OPT8241-CDK-EVM: Multiple OPT8241 Evaluation Module operation

Part Number: OPT8241-CDK-EVM

Hello,

I would like to work with 3 TOF-cameras (OPT8241 Evaluation Modul). I use Voxel SDK 0.6.10. Most frames i got are damaged.

Source Code:

String dumpFileName_1 = "depth1";
String dumpFileName_2 = "depth2";
String dumpFileName_3 = "depth3";

std::ofstream f1(dumpFileName_1, std::ios::binary | std::ios::out);
std::ofstream f2(dumpFileName_2, std::ios::binary | std::ios::out);
std::ofstream f3(dumpFileName_3, std::ios::binary | std::ios::out);

CameraSystem sys;
DepthCameraPtr depthCamera_1, depthCamera_2, depthCamera_3;
const Vector<DevicePtr> &devices1 = sys.scan();

depthCamera_1 = sys.connect(devices1[0]);
depthCamera_2 = sys.connect(devices1[1]);
depthCamera_3 = sys.connect(devices1[2]);

depthCamera_1->registerCallback(DepthCamera::FRAME_DEPTH_FRAME, [&](DepthCamera &dc, const Frame &frame, DepthCamera::FrameType c) {
		const DepthFrame *d = dynamic_cast<const DepthFrame *>(&frame);
		f1.write((char *)d->depth.data(), sizeof(float)*d->size.width*d->size.height);
		dc.stop();
});

depthCamera_2->registerCallback(DepthCamera::FRAME_DEPTH_FRAME, [&](DepthCamera &dc, const Frame &frame, DepthCamera::FrameType c) {
		const DepthFrame *d = dynamic_cast<const DepthFrame *>(&frame);
		f2.write((char *)d->depth.data(), sizeof(float)*d->size.width*d->size.height);
		dc.stop();
});

depthCamera_3->registerCallback(DepthCamera::FRAME_DEPTH_FRAME, [&](DepthCamera &dc, const Frame &frame, DepthCamera::FrameType c) {
		const DepthFrame *d = dynamic_cast<const DepthFrame *>(&frame);
		f3.write((char *)d->depth.data(), sizeof(float)*d->size.width*d->size.height);
		dc.stop();
});

for (int its = 1; its < 100; its++) {
	depthCamera_1->start();
	depthCamera_1->wait();
	
	depthCamera_2->start();
	depthCamera_2->wait();
	
	depthCamera_3->start();
	depthCamera_3->wait();
}




  • Hi,

    Is the camera working fine with Voxel Viewer software?

    Regards,
    Subhash
  • Hi,

    thank you for your replay. The camera work with Voxel Viewer. I have changed the source code. Now i start every camera in an own thread. This solve the problem with the damaged frames. But sometimes i get an error messege like:

    ---------------------------------------------------------------------------------------------------------

    WARNING: USBBulkStramer: Resetting bulk endpoint at 1542179927492660

    ERROR: USBIO: Could not transfer  307200 bytes

    ERROR: USBIO: Could not transfer  0 bytes

    ERROR: USBIO: Could not transfer  0 bytes

    WARNING: USBBulkStramer: Resetting bulk endpoint at 154217992883281

    ….

    ---------------------------------------------------------------------------------------------------------

    At this points i lost up to 20 frames.

    Best regards,

    Malte

    New Source code:

    String dumpFileName_1 = "depth1";
    String dumpFileName_2 = "depth2";
    String dumpFileName_3 = "depth3";
    
    int32_t frameCount_1 = 300;
    int32_t frameCount_2 = 300;
    int32_t frameCount_3 = 300;
    
    std::ofstream f1(dumpFileName_1, std::ios::binary | std::ios::out);
    std::ofstream f2(dumpFileName_2, std::ios::binary | std::ios::out);
    std::ofstream f3(dumpFileName_3, std::ios::binary | std::ios::out);
    
    CameraSystem sys;
    DepthCameraPtr depthCamera_1, depthCamera_2, depthCamera_3;
    const Vector<DevicePtr> &devices = sys.scan();
    
    depthCamera_1 = sys.connect(devices[0]);
    depthCamera_2 = sys.connect(devices[1]);
    depthCamera_3 = sys.connect(devices[2]);
    
    int count_1 = 0;
    int count_2 = 0;
    int count_3 = 0;
    
    depthCamera_1->registerCallback(DepthCamera::FRAME_DEPTH_FRAME, [&](DepthCamera &dc, const Frame &frame, DepthCamera::FrameType c) {
    		const DepthFrame *d = dynamic_cast<const DepthFrame *>(&frame);
    		f1.write((char *)d->depth.data(), sizeof(float)*d->size.width*d->size.height);
    		count_1++;
    		if (count_1 >= frameCount_1)
    		   dc.stop();
    	});
    	
    depthCamera_2->registerCallback(DepthCamera::FRAME_DEPTH_FRAME, [&](DepthCamera &dc, const Frame &frame, DepthCamera::FrameType c) {
    		const DepthFrame *d = dynamic_cast<const DepthFrame *>(&frame);
    		f2.write((char *)d->depth.data(), sizeof(float)*d->size.width*d->size.height);
    		count_2++;
    		if (count_2 >= frameCount_2)
    		   dc.stop();
    	});
    	
    depthCamera_3->registerCallback(DepthCamera::FRAME_DEPTH_FRAME, [&](DepthCamera &dc, const Frame &frame, DepthCamera::FrameType c) {
    		const DepthFrame *d = dynamic_cast<const DepthFrame *>(&frame);
    		f3.write((char *)d->depth.data(), sizeof(float)*d->size.width*d->size.height);
    		count_3++;
    		if (count_3 >= frameCount_3)
    		   dc.stop();
    	});
    
    std::thread t1([&]{
    		depthCamera_1->start();
    		depthCamera_1->wait();
    	});
    	
    std::thread t2([&]{
    		depthCamera_2->start();
    		depthCamera_2->wait();
    	});
    	
    std::thread t3([&]{
    		depthCamera_3->start();
    		depthCamera_3->wait();
    	});
    	
    t1.join();
    t2.join();
    t3.join();

  • Hi Malte, 

    It appears that USB is unable to handle the data for three OPT8241-CDK modules simultaneously. Could you try using two cameras and confirm if they're running properly? 

    Does reducing the frame rate help? Try a lower frame rate, like 10 fps or so. 

    Suramya

  • Hi Malte,

    Please let us know if this is still a problem.

    Regards,
    Subhash