Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

converting byte array [] to cv::Mat problems

Hi, I have a Sumix usb3 camera, and am attempting to stream into cv::Mat.

The data comes in as a byte[]:

#define FRAMEINFO_SIZEF             4096
#define MAX_FRAME_SIZE              (MAX_FRAME_SIZEX*MAX_FRAME_SIZEY)
#define MAX_FRAME_SIZE_RAW          (2*MAX_FRAME_SIZE+FRAMEINFO_SIZEF)
BYTE framemaster[MAX_FRAME_SIZE_RAW + FRAMEINFO_SIZEF];

And I run:

int W = 640;
int H = 480;
if (smx16eXX_GetFrameEx8(H_master, framemaster, MAX_FRAME_SIZE_RAW + FRAMEINFO_SIZEF))   
        {    
            std::cout << "got cameras" << std::endl;
            cv::Mat newImg = cv::Mat(H, W, CV_8UC4, framemaster);  

            cv::imshow("yes", newImg);

}

The image that I get is squashed horizontally, and doubled. Please see:

http://pasteboard.co/1qM0BFvA.jpg

I have tried other formats in place of CV_8UC4, but see other, worse issues. What am I missing ?

Thanks!

converting byte array [] to cv::Mat problems

Hi, I have a Sumix usb3 camera, and am attempting to stream into cv::Mat.

The data comes in as a byte[]:

#define FRAMEINFO_SIZEF             4096
#define MAX_FRAME_SIZE              (MAX_FRAME_SIZEX*MAX_FRAME_SIZEY)
#define MAX_FRAME_SIZE_RAW          (2*MAX_FRAME_SIZE+FRAMEINFO_SIZEF)
BYTE framemaster[MAX_FRAME_SIZE_RAW + FRAMEINFO_SIZEF];

And I run:

int W = 640;
int H = 480;
if (smx16eXX_GetFrameEx8(H_master, framemaster, MAX_FRAME_SIZE_RAW + FRAMEINFO_SIZEF))   
        {    
            std::cout << "got cameras" << std::endl;
            cv::Mat newImg = cv::Mat(H, W, CV_8UC4, framemaster);  

            cv::imshow("yes", newImg);

}

The image that I get is squashed horizontally, and doubled. Please see:

http://pasteboard.co/1qM0BFvA.jpg

I have tried other formats in place of CV_8UC4, but see other, worse issues. What am I missing ?

Thanks!

edit:

The ducumentation for the function smx16eXX_GetFrameEx8 is:

The smx16eXX_GetFrameEx8 function is used to retrieve frame data containing frame statistics, frame parameters and events to user indicated memory buffer (8 bits per pixel).
Syntax
BOOL smx16eXX_GetFrameEx8 (HANDLE H, PVOID Buffer, size_t length)
Parameters:
H [in] - HANDLE, device handle
Buffer [in] - PVOID, points to user allocated buffer
length [in] - size_t variable that contains size of the buffer
Return value:
BOOL - TRUE if function succeeds, FALSE otherwise.
Remarks
The function supplies frame data linearly converted from 16bpp to 8bpp