Skip to content

Commit 0052d46

Browse files
committed
Merge pull request opencv#23237 from hzcyf:feature/orbbec_femto_mega_support
2 parents b3c9842 + 325fe7e commit 0052d46

File tree

4 files changed

+40
-7
lines changed

4 files changed

+40
-7
lines changed

modules/videoio/src/cap_obsensor/obsensor_stream_channel_interface.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace obsensor {
3636
#define OBSENSOR_CAM_VID 0x2bc5 // usb vid
3737
#define OBSENSOR_ASTRA2_PID 0x0660 // pid of Orbbec Astra 2 Camera
3838
#define OBSENSOR_GEMINI2_PID 0x0670 // pid of Orbbec Gemini 2 Camera
39+
#define OBSENSOR_FEMTO_MEGA_PID 0x0669 // pid of Orbbec Femto Mega Camera
3940

4041
enum StreamType
4142
{

modules/videoio/src/cap_obsensor/obsensor_stream_channel_msmf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ STDMETHODIMP MSMFStreamChannel::OnEvent(DWORD /*sidx*/, IMFMediaEvent* /*event*/
499499

500500
STDMETHODIMP MSMFStreamChannel::OnFlush(DWORD)
501501
{
502-
if (streamState_ == STREAM_STARTING)
502+
if (streamState_ != STREAM_STOPED)
503503
{
504504
std::unique_lock<std::mutex> lock(streamStateMutex_);
505505
streamState_ = STREAM_STOPED;

modules/videoio/src/cap_obsensor/obsensor_uvc_stream_channel.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,24 @@ bool IUvcStreamChannel::getProperty(int propId, uint8_t* recvData, uint32_t* rec
338338
*recvDataSize = sizeof(CameraParam);
339339
memcpy(recvData, &param, *recvDataSize);
340340
}
341+
else if(OBSENSOR_FEMTO_MEGA_PID == devInfo_.pid){
342+
// return default param
343+
CameraParam param;
344+
param.p0[0] = 748.370f;
345+
param.p0[1] = 748.296f;
346+
param.p0[2] = 634.670f;
347+
param.p0[3] = 341.196f;
348+
param.p1[0] = 374.185f;
349+
param.p1[1] = 374.148f;
350+
param.p1[2] = 317.335f;
351+
param.p1[3] = 170.598f;
352+
param.p6[0] = 1280;
353+
param.p6[1] = 720;
354+
param.p7[0] = 640;
355+
param.p7[1] = 360;
356+
*recvDataSize = sizeof(CameraParam);
357+
memcpy(recvData, &param, *recvDataSize);
358+
}
341359
else{
342360
rst &= setXu(2, OB_EXT_CMD5, sizeof(OB_EXT_CMD5));
343361
rst &= getXu(2, &rcvData, &rcvLen);

modules/videoio/src/cap_obsensor_capture.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ VideoCapture_obsensor::VideoCapture_obsensor(int index) : isOpened_(false)
3434
{
3535
static const obsensor::StreamProfile colorProfile = { 640, 480, 30, obsensor::FRAME_FORMAT_MJPG };
3636
static const obsensor::StreamProfile depthProfile = {640, 480, 30, obsensor::FRAME_FORMAT_Y16};
37-
static const obsensor::StreamProfile gemini2depthProfile = {1280, 800, 30, obsensor::FRAME_FORMAT_Y14};
38-
static const obsensor::StreamProfile astra2depthProfile = {640, 480, 30, obsensor::FRAME_FORMAT_Y14};
37+
static const obsensor::StreamProfile gemini2DepthProfile = {1280, 800, 30, obsensor::FRAME_FORMAT_Y14};
38+
static const obsensor::StreamProfile astra2DepthProfile = {640, 480, 30, obsensor::FRAME_FORMAT_Y14};
39+
static const obsensor::StreamProfile megaColorProfile = {1280, 720, 30, obsensor::FRAME_FORMAT_MJPG};
40+
static const obsensor::StreamProfile megaDepthProfile = {640, 576, 30, obsensor::FRAME_FORMAT_Y16};
3941

4042
streamChannelGroup_ = obsensor::getStreamChannelGroup(index);
4143
if (!streamChannelGroup_.empty())
@@ -46,11 +48,17 @@ VideoCapture_obsensor::VideoCapture_obsensor(int index) : isOpened_(false)
4648
switch (streamType)
4749
{
4850
case obsensor::OBSENSOR_STREAM_COLOR:
49-
channel->start(colorProfile, [&](obsensor::Frame* frame) {
51+
{
52+
auto profile = colorProfile;
53+
if(OBSENSOR_FEMTO_MEGA_PID == channel->getPid()){
54+
profile = megaColorProfile;
55+
}
56+
channel->start(profile, [&](obsensor::Frame* frame) {
5057
std::unique_lock<std::mutex> lk(frameMutex_);
5158
colorFrame_ = Mat(1, frame->dataSize, CV_8UC1, frame->data).clone();
5259
frameCv_.notify_all();
5360
});
61+
}
5462
break;
5563
case obsensor::OBSENSOR_STREAM_DEPTH:
5664
{
@@ -59,11 +67,13 @@ VideoCapture_obsensor::VideoCapture_obsensor(int index) : isOpened_(false)
5967

6068
obsensor::StreamProfile profile = depthProfile;
6169
if(OBSENSOR_GEMINI2_PID == channel->getPid()){
62-
profile = gemini2depthProfile;
70+
profile = gemini2DepthProfile;
6371
}
6472
else if(OBSENSOR_ASTRA2_PID == channel->getPid()){
65-
66-
profile = astra2depthProfile;
73+
profile = astra2DepthProfile;
74+
}
75+
else if(OBSENSOR_FEMTO_MEGA_PID == channel->getPid()){
76+
profile = megaDepthProfile;
6777
}
6878

6979
channel->start(profile, [&](obsensor::Frame* frame) {
@@ -127,6 +137,10 @@ bool VideoCapture_obsensor::retrieveFrame(int outputType, OutputArray frame)
127137
grabbedDepthFrame_ = grabbedDepthFrame_*0.8;
128138
grabbedDepthFrame_.copyTo(frame);
129139
}
140+
else if(OBSENSOR_FEMTO_MEGA_PID == streamChannelGroup_.front()->getPid()){
141+
Rect rect(0, 0, 640, 360);
142+
grabbedDepthFrame_(rect).copyTo(frame);
143+
}
130144
else{
131145
grabbedDepthFrame_.copyTo(frame);
132146
}

0 commit comments

Comments
 (0)