in-code scanning of com port and acquierement of a stills image

1 Ansicht (letzte 30 Tage)
matar maoz
matar maoz am 24 Jan. 2011
Hello
I am making a model video- game wireless pistol using a camera, ask transciever and matlab. I am taking an rgb photo and sending it in blocks of 8 bit to the computer using rs232.
i need to receive the dismantled information into MATLAB, and rebuild it.
for the transmittion i am using a rs232 protocol, because i understood that using bluetooth is very complicated or not possible when not using VISA's of the specific vendors (The vendor name can be agilent, ni, or tek, as specified in the MATLAB help of the instrument controll toolbox).
i have serveral problems.
i cant manage to find a demo code, or a toolbox fit to receive packs of an entire frame from the com port, and rebuild it using a code written in the M-file.
all i can do now is to use the test & measurement tool. in it i can create an instrument object for another PC and transfer ASCII for a short period of time.
what i want to do is transfer an entire picture to MATLAB and process it using the image processing toolbox.
i'd apprecciate some help.
MATAR

Antworten (2)

Walter Roberson
Walter Roberson am 24 Jan. 2011
Will the frame always be the same size? If so, then just fread the appropriate number of bytes from the serial port and reshape() it in to the RGB array. If your image needs to be more precise than 8 bits per component then there is some extra work to do; there is also some extra work to do if you interleave R G and B components for each pixel instead of transmitting all R, then all G, then all B.
The same general technique holds if there is additional fixed-sized information to transmit.
Things only start to get notably more complicated if you are sending variable-length packets of information, perhaps representative of different kinds of information.

Ankit Desai
Ankit Desai am 2 Feb. 2011
If you are facing problems in getting the Serial Port communication going the way you want, here are some links that might help you.
For examples and demo code on using Serial port from MATLAB command line, you might want to check out the online documentation.
Depending on whether the frame size is constant or not, you might want to take a look at using events and callbacks. If the frame size is constant, you can define a BytesAvailableFcn that does the frame read and rebuild.
If the frame size is big and require a long time to transfer, make sure to update the Timeout property accordingly.
Hopefully the online documentation will provide you with enough details to resolve the issue you are facing regarding the Serial Port communication.
All the best.

Kategorien

Mehr zu Instrument Control Toolbox Supported Hardware finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by