Ask Your Question
0

Cube Eye camera (3D depth camera) and Opencv

asked 2019-12-07 16:05:02 -0500

IIVirusII gravatar image

updated 2019-12-08 04:09:35 -0500

Hi, I am try to create a small project, that needs hand gestures recognition and I am trying to connect cube eye camera to opencv but I am failing. Is there any possible way to connect the two together in code. Adding that cube eye does have a SDK and a library.

API_MTF header code:

ifndef MTF_API_H

define MTF_API_H

/**

*@file MTF_API.h

*@brief MTF_API DLL's default header file.

*@details Meere ToF Camera(MTF) SDK (Windows Standard DLL Version) Copyright(c) Meerecompany, 2014 All rights reserved.

*@version 2.6 *@dete 2018/05/08

*@author Support@cube-eye.co.kr

*/

ifndef _MTF_API_H_

define _MTF_API_H_

ifdef _USRDLL

#define DLLFunction __declspec(dllexport)

else

#define DLLFunction __declspec(dllimport)

endif

//#ifndef FALSE //#define FALSE 0 //#endif // //#ifndef TRUE //#define TRUE 1 //#endif

namespace MTF_API {

#define MAX_DEVICE 10
typedef int mtfHandle;


typedef enum _mtfError
{
    ERROR_NO        = 1,    //return true(1)
    ERROR_FAIL      = 0,    //return false(0)
    ERROR_HANDLE    = -1,   //return error code -1
    ERROR_OPEN      = -2,   //return error code -2
    ERROR_TIME_OUT  = -3,   //return error code -3
    ERROR_PARAM     = -4,   //return error code -4
    ERROR_READ_DATA = -5,   //return error code -5

} mtfError;//Error Code List

typedef enum _mtfFilter
{
    FILTER_NO           = 0,
    FILTER_EDGE         = 1,

} mtfFilter;//Filtering Type

typedef enum _mtfUndistortionMode
{
    DISTORTION_NO           = 0,//Undistortion Off
    DISTORTION_MODE1        = 1,//Undistortion On(recommended)
    DISTORTION_MODE2        = 2,//Undistortion On + object boundaries jagged edge Interpolation On (high cpu load)
    DISTORTION_MODE3        = 3,//Undistortion On + object boundaries jagged edge Interpolation On & boundary Remove On (high cpu load)

} _mtfUndistortionMode;//Undistortion Mode Type

typedef struct _mtfDeviceInfo
{
    mtfHandle mtfHnd;           //Device Handle
    char szDevPath[256];        //Device Path
    char szVendor[256];         //Vendor Name
    char szName[256];           //Name
    char szSerialNum[256];      //Sereial Number
    unsigned short nVendorId;   //Vendor ID
    unsigned short nProductId;  //Product ID
    unsigned short nDeviceType; //Device Type(0:Only Depth, 1:Depth+RGB)

} mtfDeviceInfo;//Device Infomation

typedef struct _mtfFrameInfo
{
    int nWidth;                 //Image Width
    int nHeight;                //Image Height
    long nFrameIndex;           //Frmae Index
    long nTimeStamp;        //Frame Timestamp

} mtfFrameInfo;//Device Infomation

typedef struct _mtfIntrinsicParam//Camera Intrinsic Parameter
{
    float fFx;  //Focal length X
    float fFy;  //Focal length Y
    float fCx;  //Principal point X
    float fCy;  //Principal point Y

} mtfIntrinsicParam;//lens intrinsic parameter

typedef struct _mtfDistortionParam//Camera Distortion Parameter
{
    float fK1;  //Distortion K1
    float fK2;  //Distortion K2
    float fK3;  //Distortion K3
    float fP1;  //Distortion P1
    float fP2;  //Distortion P2
    float fSkew;

} mtfDistortionParam;//lens distortion parameter

typedef struct _mtfExtrinsicParam
{
    float fR11;
    float fR12;
    float fR13;
    float fR21;
    float fR22;
    float fR23;
    float fR31;
    float fR32;
    float fR33;
    float fTx;
    float fTy;
    float fTz;

} mtfExtrinsicParam;//extrinsic parameter(only depth-rgb camera model)

typedef struct _mtfCameraSpacePoint
{
    float fX;                   //X Coordinates (unit: m)
    float fY;                   //Y Coordinates (unit: m)
    float fZ;                   //Z Coordinates (unit: m)

} mtfCameraSpacePoint;//3D XYZ Coordinates

typedef struct _mtfDepthSpacePoint
{
    float fPointX;              //X Pixel Point (unit: pixel pos)
    float fPointY;              //Y Pixel Point (unit: pixel pos)
    float fDepth;               //Depth (unit: mm)

} mtfDepthSpacePoint;//X,Y Pixel, Depth

extern "C"
{
    /**
    *
    * @author   K.W.Yeom
    * @date     2017. 11. 16.
    * @brief    Get Device List
    * @details  number of connectable devices and information
    * @Param    mtfDeviceInfo pDevInfo - device information
    * @Param    int nDevCount - number of connectable devices
    * @return   void
    *
    */
    DLLFunction int mtfGetDeviceList(mtfDeviceInfo *pDevInfo, int ...
(more)
edit retag flag offensive close merge delete

Comments

my 2 ct.: go for the sdk.

try to find out, how to get an image from there, show us the resp. code, then we can help you to integrate opencv code.

berak gravatar imageberak ( 2019-12-08 03:43:05 -0500 )edit
1

I just edited the code from the SDK in the question.

IIVirusII gravatar imageIIVirusII ( 2019-12-08 04:19:56 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-12-08 05:45:29 -0500

berak gravatar image

i neither have the device, nor the sdk, so all of it "with a grain of salt", but it might boil down to something like this:

initialization (once):

Mat rgb(480,640,CV_8UC3); 
Mat depth(240,320,CV_16UC1);
Mat ampli(240,320,CV_16UC1);
mtfFrameInfo stFrameInfo;

unsigned short** depth_amp = new unsigned short *[2];
depth_amp [0] = (unsigned short*)depth.data;
depth_amp [1] = (unsigned short*)ampli.data;


//1. get connect device list
MTF_API::mtfHandle      m_pHnd;                 //control device handle
MTF_API::mtfDeviceInfo  m_pDevInfo[MAX_DEVICE]; //device info
int nDevCount = 0;
MTF_API::mtfGetDeviceList(m_pDevInfo, &nDevCount);
//2. set control device handle
m_pHnd = m_pDevInfo[0].mtfHnd;//deivce 0 handle
//3.open device
CV_Assert(MTF_API::mtfDeviceOpen(m_pHnd) == MTF_API::ERROR_NO);
MTF_API::mtfReadBufInit(m_pHnd);

per frame:

MTF_API::mtfGrabStart(m_pHnd);

//Get Depth Data From device
MTF_API::mtfReadFromDevice(m_pHnd, (unsigned short**)depth_amp, &stFrameInfo) ;
//Get RGB Depth Data From device
MTF_API::mtfReadFromDevice_RGB888(m_pHnd, (unsigned char*)rgb.data, &stFrameInfo);

MTF_API::mtfGrabStop(m_pHnd);
edit flag offensive delete link more

Comments

Thanks, I will try it.

IIVirusII gravatar imageIIVirusII ( 2019-12-08 05:56:37 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-12-07 16:05:02 -0500

Seen: 57 times

Last updated: Dec 08 '19