Converting matlab array to std::vector<unsigned char*>
13 views (last 30 days)
Show older comments
Hi,
I am not familiar with Mex or C++, but I am using the MicroManager 2.0 Core API ('mmc' object in the following matlab examples), and I am trying to pass an image sequence to one of its function.
void CMMCore::loadSLMSequence ( const char * deviceLabel, std::vector< unsigned char *> imageSequence )
I have the image sequence as a 3D matrix of uint8's in my workspace under the name 'mov'. The following does not work:
mmc.loadSLMSequence(DMDname,mov(:))
It throws the following error: "No method 'loadSLMSequence' with matching signature found for class 'mmcorej.CMMCore'."
I know the method exists, but it is probably not receiving the imageSequence data in the right format. For reference the function setSLMImage:
void CMMCore::setSLMImage (const char *slmLabel, unsigned char *pixels)
accepts this call:
mmc.setSLMImage(DMDname,img(:))
with 'img' a 2D uint8 matlab array.
My first question is, is there a way to get my 'mov' variable accepted by the CMMCore API? (I am not sure this question even makes sense as it might have more to do with the API itself)
My second question is, should I try to do the type conversion myself using MEX? I tried several variations of the following line:
std::vector<unsigned char> outarr = inputs[0]
With inputs[0] being 'mov', but I always get something like "error: conversion from 'matlab::data::Array' to non-scalar type 'std::vector<unsigned char>' requested" when I try to compile with mex.
Like I said I'm a newbie, and any help would be appreciated. Ideally I could write a function "myconverter" that would allow me to do something like this:
mmc.loadSLMSequence(DMDname,myconverter(mov))
Thank you!
JB
0 Comments
Answers (0)
See Also
Categories
Find more on Call C++ from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!