Translation of serial camera data to RGB image.

10 views (last 30 days)
Being a fairly new Matlab user, I have trouble translating the bytes I get back from a serial camera to a viewable, RGB565 image. The camera I'm using is this and so far I've managed to get 153600 bytes, back (320*240*2 for a 16 bit image) and store it in a 153600x1 column vector (not mentioning the grayscale image case with which I had no problem - what I did there was just reshape my 76800 bytes to a 320x240 matrix and then used imshow).
So my main question is how can I translate this vector to a proper matrix that I can view with imshow for example. I understand that an RGB image is an m-by-n-by-3 array but I can't seem to figure out how to reshape my vector as such.
Thank you very much in advance!
  4 Comments
aseok
aseok on 3 Jul 2015
Hello.
What is format of 'frame' vector ? my mean is how RGB565 data of raws and columns of a frame are provided in this vector? What is the frame_rot variable? Thanks.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 25 Oct 2012
If the two bytes of each 16 bit value occur one after the other, then use typecast() to convert the two bytes to a uint16 pair. After that you can reshape(), and possibly permute() if you need to move the planes around.
  4 Comments
M. Kiriakos
M. Kiriakos on 26 Oct 2012
I guess you mean trying something along those lines, right? I will definitely have to look into it as I am not that familiar with Matlab and coding in general. Do you think a modification of the above code (the one from Stackoverflow I mean) would work in my case?

Sign in to comment.

More Answers (2)

Image Analyst
Image Analyst on 25 Oct 2012
Well why did it end up as a 1D list of pixels? Didn't you use getsnapshot()?
  3 Comments
Image Analyst
Image Analyst on 25 Oct 2012
Mine are too - universal serial bus. I didn't look up his/hers until now. My advice would be to dump that primitive OEM camera and get something easier to work with. Why spend all that time trying to get that thing to work when there are plenty of inexpensive cameras or webcams that will work instantly right out of the box? It's just not worth the time and trouble if you can't get it up and running in short order.
M. Kiriakos
M. Kiriakos on 26 Oct 2012
I understand what you're saying and thank you for your response. I just think that the point is to solve the problem I am having with this camera. Not get another one because I couldn't solve the problem with this one... I wasn't aware of the getsnapshot() command to be honest but judging from Walter's post, I guess it doesn't work with a serial camera. Or am I mistaken? Unfortunately I will not be able to test it until tomorrow but nevertheless a serial object is indeed created for my camera with the serial command.
As for the 1D, I think this is just the way the camera outputs data. In a serial manner and then I just store them in a vector. As I mentioned above, I didn't have any problem manipulating the data in the grayscale case as it was just the intensity values. But the RGB case is a little trickier for me...

Sign in to comment.


aseok
aseok on 3 Jul 2015
Hello. What is format of 'frame' vector ? my mean is how RGB565 data of raws and columns of a frame are provided in this vector? What is the frame_rot variable? Thanks.

Categories

Find more on MATLAB Support Package for IP Cameras 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!