Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

converting byte array [] to cv::Mat problems

$
0
0
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](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

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>