- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Guys,
I'm using the F200 and visual studio 2012 to develop object tracking algorithm. But I have problem when I try to obtain the image data. When I use the QueryStreamProfileSet function to get a ProfileSet, it always returns PXC_STATUS_ITEM_UNAVAILABLE.
I'm sure that my SDK and the camera works well. Because when I use the demo provided by SDK, I can get the image show. But now I don't want to use the PXCSenseManager and I want to get the image and processing it using OpenCV. My code are attached (I learned this code from the other forum and it works for R200 camera). Also, I can find my camera by IUID and the available stream type is COLOR, DEPTH, and IR. But when I call the QueryStreamProfileSet function, it always returns PXC_STATUS_ITEM_UNAVAILABLE.
Could someone help me check what's wrong? Did I miss some crucial steps?
#include <windows.h> #include "iostream" #include "resource.h" #include "pxcdefs.h" #include <cv.h> #include <highgui.h> using namespace std; using namespace cv; pxcStatus retStatus; //函数的返回状态 PXCSession *Session = PXCSession::CreateInstance(); pxcUID f200_iuid = 1129862729; #define F200_IUID f200_iuid;//需要测试才能知道这个值是多少 /** **查找设备,获取并初始化指定摄像头的Device接口 **/ PXCCapture::Device* ImplSeek(pxcUID iuid){ cout<<"Destination IUID:"<<iuid<<endl; PXCCapture *Capture; PXCCapture::Device *rsDevice = NULL; for(uint_fast8_t idx = 0; idx < UINT_FAST8_MAX; idx += 1){ PXCSession::ImplDesc Impl = {}; Impl.group = PXCSession::IMPL_GROUP_SENSOR; Impl.subgroup = PXCSession::IMPL_SUBGROUP_VIDEO_CAPTURE; retStatus = Session->QueryImpl(&Impl, idx, &Impl); if(retStatus < PXC_STATUS_NO_ERROR) continue; cout<<"-------------------------------------------"<<endl; wcout<<"DCM:"<<Impl.friendlyName<<endl; cout<<"***IUID is:"<<Impl.iuid<<endl; retStatus = Session->CreateImpl(&Impl, &Capture); if(retStatus < PXC_STATUS_NO_ERROR) continue; PXCCapture::DeviceInfo dinfo = { 0 }; retStatus = Capture->QueryDeviceInfo(idx, &dinfo); if(retStatus < PXC_STATUS_NO_ERROR){ cout<<"Detail Information:Fail to query device"<<endl; continue; } wcout<<"Details:"<<endl; wcout<<"Name:"<<dinfo.name<<", DCM index:"<<dinfo.didx<<endl; wcout<<"Available Stream Type: "; if(dinfo.streams & PXCCapture::STREAM_TYPE_COLOR) cout<<"COLOR"; if(dinfo.streams & PXCCapture::STREAM_TYPE_DEPTH) cout<<", DEPTH"; if(dinfo.streams & PXCCapture::STREAM_TYPE_IR) cout<<", IR"; if(dinfo.streams & PXCCapture::STREAM_TYPE_LEFT) cout<<", LEFT"; if(dinfo.streams & PXCCapture::STREAM_TYPE_RIGHT) cout<<", RIGHT."; cout<<endl; wcout<<"---firmware version:V---"<<dinfo.firmware[0]<<"."<<dinfo.firmware[1]<<"."<<dinfo.firmware[2]<<"."<<dinfo.firmware[3]<<endl;//顺便检查一下是否要升级 wcout<<"---serial: -----"<<dinfo.serial<<endl; // wcout<<"---did:----"<<dinfo.did<<endl; if(Impl.iuid != iuid){ cout<<"The IUID of this device is not matched"<<endl; continue; } cout<<"================================================"<<endl; wcout<<"Bingo! Find the matched device:"<<Capture->DeviceModelToString(dinfo.model)<<". "<<endl; rsDevice = Capture->CreateDevice(idx);//connected to the device if(rsDevice == NULL){ cout<<"rsDevice is NULL"<<endl; continue; } return rsDevice; } if(rsDevice == NULL){ cout<<"\nNo matched device"<<endl; } return NULL; } /** **Initial Stream Type **/ void StreamInit(int Profile_idx, PXCCapture::Device *dstDevice, bool Dualeye){ PXCCapture::Device::StreamProfileSet ProfileSet = {}; if(Dualeye){ PXCCapture::StreamType scope = PXCCapture::STREAM_TYPE_COLOR | PXCCapture::STREAM_TYPE_DEPTH | PXCCapture::STREAM_TYPE_LEFT | PXCCapture::STREAM_TYPE_RIGHT; retStatus = dstDevice->QueryStreamProfileSet(scope, Profile_idx, &ProfileSet); if(retStatus == PXC_STATUS_ITEM_UNAVAILABLE){ cout<<"Item not find"<<endl; exit(0); } ProfileSet.color.options = ProfileSet.depth.options = ProfileSet.right.options = ProfileSet.left.options = PXCCapture::Device::STREAM_OPTION_STRONG_STREAM_SYNC; }else{ PXCCapture::StreamType scope = PXCCapture::STREAM_TYPE_COLOR | PXCCapture::STREAM_TYPE_DEPTH | PXCCapture::STREAM_TYPE_IR; dstDevice->QueryStreamProfileSet(scope, Profile_idx, &ProfileSet); ProfileSet.color.options = ProfileSet.depth.options = ProfileSet.ir.options = PXCCapture::Device::STREAM_OPTION_STRONG_STREAM_SYNC; } if(dstDevice->IsStreamProfileSetValid(&ProfileSet)){ dstDevice->SetStreamProfileSet(&ProfileSet); cout<<"Ready"<<endl; }else{ cout<<"Bad ProfileSet"<<endl; } } struct Frames{ Mat Color;//RGB image matrix Mat Depth;//depth image matrix Mat IR;//IR image matrix Mat IR_; }; Frames Update(PXCCapture::Device *Device, bool Dualeye = true, PXCCapture::StreamType scope = PXCCapture::STREAM_TYPE_COLOR | PXCCapture::STREAM_TYPE_DEPTH){ PXCCapture::Sample FrameSamples; PXCImage::ImageData color8, depth16, _ir, biol16, bior16; retStatus = Device->ReadStreams(scope, &FrameSamples); if(retStatus < PXC_STATUS_NO_ERROR){ cout<<"ReadStreams Error"<<endl; exit(0); } Frames frames; if(Dualeye){ #pragma region dualeye if(scope & PXCCapture::STREAM_TYPE_COLOR){ FrameSamples.color->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_RGB24,PXCImage::ROTATION_0_DEGREE, PXCImage::OPTION_ANY, &color8); Mat Color(Size(320,240), CV_8UC3, color8.planes[0]); frames.Color = Color; FrameSamples.color->ReleaseAccess(&color8); } if(scope & PXCCapture::STREAM_TYPE_DEPTH){ FrameSamples.depth->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_DEPTH,PXCImage::ROTATION_0_DEGREE, PXCImage::OPTION_ANY, &depth16); Mat Depth(Size(320,240), CV_16UC1, depth16.planes[0]); frames.Depth = Depth; FrameSamples.depth->ReleaseAccess(&depth16); } if (scope & PXCCapture::STREAM_TYPE_LEFT) { FrameSamples.left->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_Y16, PXCImage::ROTATION_0_DEGREE, PXCImage::OPTION_ANY, &biol16); Mat StroL(Size(320, 240), CV_16UC1, biol16.planes[0]); frames.IR = StroL; FrameSamples.left->ReleaseAccess(&biol16); } if (scope & PXCCapture::STREAM_TYPE_RIGHT) { FrameSamples.right->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_Y16, PXCImage::ROTATION_0_DEGREE, PXCImage::OPTION_ANY, &bior16); Mat StroR(Size(320, 240), CV_16UC1, bior16.planes[0]); frames.IR_ = StroR; FrameSamples.right->ReleaseAccess(&bior16); } #pragma endregion } else { #pragma region _ if (scope & PXCCapture::STREAM_TYPE_COLOR) { FrameSamples.color->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_RGB24, PXCImage::ROTATION_0_DEGREE, PXCImage::OPTION_ANY, &color8); Mat Color(Size(640, 480), CV_8UC3, color8.planes[0]); frames.Color = Color; FrameSamples.color->ReleaseAccess(&color8); } if (scope & PXCCapture::STREAM_TYPE_DEPTH) { FrameSamples.depth->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_DEPTH, PXCImage::ROTATION_0_DEGREE, PXCImage::OPTION_ANY, &depth16); Mat Depth(Size(640, 480), CV_16UC1, depth16.planes[0]); frames.Depth = Depth; FrameSamples.depth->ReleaseAccess(&depth16); } if (scope & PXCCapture::STREAM_TYPE_IR) { FrameSamples.ir->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_Y16, PXCImage::ROTATION_0_DEGREE, PXCImage::OPTION_ANY, &_ir); Mat _IR(Size(640, 480), CV_16UC1, _ir.planes[0]); frames.IR = _IR; FrameSamples.left->ReleaseAccess(&_ir); } #pragma endregion } FrameSamples.ReleaseImages(); return(frames); } int main(){ PXCCapture::Device *F200_Device; F200_Device = ImplSeek(f200_iuid); StreamInit(6, F200_Device, true); cout<<"Streaming..."<<endl; for(;;){ Frames F200_rgbd = Update(F200_Device); Mat Depth8 = F200_rgbd.Depth.clone(); (Depth8 /= 15).convertTo(Depth8, CV_8UC1, 1, 20); //show imshow("Depth8", Depth8); imshow("Color",F200_rgbd.Color); waitKey(1); } return 0; }
Link Copied

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page