-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Camera Image Capture Enhancement #7
Comments
HI,
|
Hi, Can you be more specific? What problems are you having? Thanks, On Sat, Jul 23, 2016 at 9:19 PM, nathansudomeyer [email protected]
Jeff Perry |
Hello again jeffsp, I'm working with Nathan who posted above. The major problem we're facing is getting the contents of the ImageList and Image objects into matlab as a raw data feed (like they do here in the C++ API ), in order to use the motion tracking tools Matlab provides. There is still the "code your own video driver option" but we couldn't find many informations on the leap motion's camera models and specs so we were hoping to adapt matleap to get the image feed. I think we're not that far from the solution but I can't quite figure out why this doesn't work. Here is the modified matleap.h we have :
We tried to keep it as close as possible to the original so you can just replace the code in your matleap.h to test it, but the part on the bottom mystifies us. We can't seem to get the contents of the left (or right, for that matter) camera images. Sorry if my explanations are shoddy, if you have any insight it would be wonderful. |
Hello Pierre, I think you will need to add the image list struct Frame Maybe something like
Then in frame_grabber::get_frame current_frame.image_list = f.images(); I think that is probably all you need in frame_grabber::get_frame. The hard part is to stuff those images into mxArrays so that they can be Look at "void get_frame (int nlhs, mxArray *plhs[])" You will likely need to add another field called maybe 'images' to the This field will be a 1XN array of image structs. You will need to call mxCreateStructMatrix to create a Matlab image struct Then you can create the fields for width and height mxSetFieldByNumber You will also need to create a field in the image struct for the raw data. Look at "create_and_fill()". You could do something similar, but that This is the way I would go about adding this support, for what it's worth. Please let me know if this is helpful and get back to me. It would be great Thanks, On Tue, Jul 26, 2016 at 9:02 AM, Joringer [email protected] wrote:
Jeff Perry |
Thank you very much for the answer, we'll dig in and keep you updated :). |
Oh we have tried following your directions, we've come up with this version of matleap.cpp
We are having trouble getting the values of the The major error Matlab displays here is something like "C2664, can't convert const unsigned char Cheers, |
What is the problem you are having? Does it compile but the data is You are checking the image list to make sure it has at least one image, but C++ has 0-based indexing. If you want the first image, you need to say.
On Wed, Jul 27, 2016 at 2:48 PM, Pierre Gaumant [email protected]
Jeff Perry |
Hi Jeff, In .cpp :
In Header :
In test :
We have tried following your directions but the execution of our version of test_matleap failed, indicating that : Struct contents reference from a non-struct array object. Would you know how to pass this step ? Thanks for your precious help. Nathan |
I have not compiled the following code, but I was thinking something more 1 mxArray *create_and_fill_raw (const Leap::ImageList &images) 2 { 3 if (images.size () < 1) 4 return NULL; 5 6 // Assumes the frames are all the same size 7 const int w = images[0].width (); 8 const int h = images[0].height (); 9 const int dims[3] = {images.size (), h, w}; 10 11 // This will terminate the mex-file if there is not enough memory 12 mxArray *r = mxCreateNumericArray (3, dims, mxUINT8_CLASS, 14 unsigned char *p = mxGetPr (r); 15 for (int n = 0; n < images.size (); ++n) 16 { 17 for (int i = 0; i < h; ++i) 18 { 19 for (int j = 0; j < w; ++j) 20 { 23 } 24 } 25 return r; 26 } 27 28 ... 29 30 void get_frame (int nlhs, mxArray *plhs[]) 31 { 32 // get the frame 33 const matleap::frame &f = fg->get_frame (); 34 // create matlab frame struct 35 const char *frame_field_names[] = 36 { 37 "id", 38 "timestamp", 39 "images", 40 }; 41 int frame_fields = sizeof (frame_field_names) / sizeof 44 mxSetFieldByNumber (plhs[0], 0, 0, mxCreateDoubleScalar (f.id)); 45 mxSetFieldByNumber (plhs[0], 0, 1, mxCreateDoubleScalar 48 49 ... 50 51 struct frame 52 { 53 int64_t id; 54 int64_t timestamp; 55 Leap::ImageList images; 56 }; On Thu, Jul 28, 2016 at 9:02 PM, nathansudomeyer [email protected]
Jeff Perry |
Thanks Jeff |
Why is f.images empty ? However we perfectly get id and timestamp... |
You might try putting some mexPrintf()'s in your code to see what's mxArray *create_and_fill_images (const Leap::ImageList &images)
On Fri, Jul 29, 2016 at 1:08 PM, nathansudomeyer [email protected]
Jeff Perry |
hello guys, Have you had any success in implementing this function in matleap? I really need to extract a raw image from one of the IR cameras of LEAP using matleap Thank you very much Michele |
The Leap SDK has support for capturing raw camera images. It would be nice to add this support to Matleap. This features has been requested by several people.
The text was updated successfully, but these errors were encountered: