Discussion:
Reading Image Data from Serial Port
(too old to reply)
Hosangadi
2008-08-09 12:10:04 UTC
Permalink
Dear Friends, I have a Embedded Logger which has a VGA camera attached to it mainly used in  remote monitoring, we are trying different lens for that camera.I need to develop an application in LabView to acquire the image data from the device and display it on my PC so that we can test the camera lens.Basically my embedded device reads the image from camera and it will store it in a buffer. Also that device has a serial interface(RS232) through which I can transfer the buffer to PC. But I need some help on receiving that Image data via serial port of my PC and to display at the fastest rate possible so that we can test our camera easily presently we are doing it using GPRS, I am using TCP functions of LabView but its very slow due to Telco problems, data size of each Image will be around 5KB!.Please suggest me on this.Thank you in advance!Regards,Hosangadi
JoeLabView
2008-08-09 12:40:04 UTC
Permalink
What are the specs for the camera using the serial port?  I would have expected TCP to be much faster than serial communication.
However, if you do want to use the serial port, you should be able to communicate with it and receive the image using the available examples.  I should probably ask if you have used LabVIEW serial communication before.
In any case, look within the Help menu and select Find Examples.  Do a search on "serial".  Double-click on the work serial in the box below search.  It will list approx 9 examples.  Select the top one called "Advanced Serial Write and Read.vi"
Select the appropriate Visa Resource Name (COM port) and configure the port appropriately for maximum speed, according to the manufacturer's recommendations (specs).  You can also play with the input buffer size  You will need to select if you write with a termination character or not (push buttons).  It is the carriage return.
Your data will be read as a string, so it may not look right.  That's okay... It will most likely be hexadecimal characters.  You will then need to convert this to hexadecimal numbers and write it to a binary file.  If you need help, simply post the character string that you read from the serial port so that we can provide assistance.
Start with this and let us know how it goes.
R
 Message Edited by JoeLabView on 08-09-2008 08:13 AM
Hosangadi
2008-08-09 12:40:05 UTC
Permalink
Hi, Many thanks for quick response, basically we are not aware of the camera spec as its a third party propriety, but it doesnt matter as I need to acquire Image from a data logger to which that camera is attached, My data logger supports serial communication(Normal 9600 bps). I am quite new to Lab View I am more in to embedded systems. Yes TCP should be faster but I dont have direct TCP interface with data logger I need to use GPRS to transfwer Image which is taking more time!The communication is as below:VGA Camera-----Unknown Protocol------>Datalogger(Programmable)--------RS232---------->PCI have APIs for camera to capture Images in my Datalogger which I will call in my firmware and API returns Image data in a Buffer.I also have Serial Port APIs to send both string and data.I tried to send small strings from datalogger to PC and read it using Advanced Serial Read.vi it works fine, but when I tried to send Image data about 4.5KB I couldnt receive anything. Also pls let me know whether I can use IMAQ functions as I have IMAQ modules.I am not directly dealing with Camera I communicate with the Datalogger. I think you all clear about my need now!
Hosangadi
2008-08-09 13:40:05 UTC
Permalink
Serial communication I can use: 57.600 baud, no parity, 8 data bits, 1 stop bit.
JoeLabView
2008-08-09 14:10:05 UTC
Permalink
Hosangadi wrote:VGA Camera-----Unknown Protocol------>Datalogger(Programmable)--------RS232---------->PCI have APIs for camera to capture Images in my Datalogger which I will call in my firmware and API returns Image data in a Buffer.I also have Serial Port APIs to send both string and data.I tried to send small strings from datalogger to PC and read it using Advanced Serial Read.vi it works fine, but when I tried to send Image data about 4.5KB I couldnt receive anything. Also pls let me know whether I can use IMAQ functions as I have IMAQ modules.I am not directly dealing with Camera I communicate with the Datalogger. I think you all clear about my need now!



So you are only concerned about the serial interface to and from the Datalogger.  The API that you have available, is it in the form of a dll?  If so, then you may need a different approach.  Can you describe this API?
 
After you have received the image data and saved it as an image file (maybe done by the API??), you will then be able to use the IMAQ functions as you would with any image. 
 
The potential difference between getting the image data directly from the serial communication within LabVIEW versus the API is that the API may prepare the image header information directly into the file, whereas we would have to see the data if you use the serial communication.  It is possible that the camera does this already.  Which is why you would need to describe the API.
 
R
Hosangadi
2008-08-09 14:40:07 UTC
Permalink
Hi JLV, API is not windows API ,I refer to the datalogger API, using which I can take the snapshot from the camera attached to it, This API is for Datalogger firmware not for PC software.API is like thuis:// Take a snapshotsize := camSnapshot(res := 3, pic := ADDR(buffer), picsize :=SIZEOF(buffer));here res:Resolutionwhen I call this API in my firmware application of Datalogger by which datalogger issues a command to the Camera to take the Image and Recieve the Imgae in JPEG format, Last time I tried to tansfer the "buffer" throght GPRS socket to Server and I received it using TCP Listen, Read functions of LabView as a string and I wrote this string from TCP in to a JPEG file using write charecters to file, I ws successful in gettiong the Image that way! but speed is the problem on that approach, I need same buffer to be transferred using Serial port and read it in my PC write data in to a Image file and display the Image on my LabView application, So my major concern is about acquiring this JPEG pixel data through a serial port and displaying it on Labview application.Buffer will be having pixel data which can be directly written in to a JPEG file to get Image.
muks
2008-08-09 12:40:04 UTC
Permalink
Dear Friends,I have a Embedded Logger
which has a VGA camera attached to it mainly used in  remote
monitoring, we are trying different lens for that camera.I need to
develop an application in LabView to acquire the image data from the
device and display it on my PC so that we can test the camera
lens.Basically my embedded device reads the image from camera and it
will store it in a buffer. Also that device has a serial
interface(RS232) through which I can transfer the buffer to PC. But I
need some help on receiving that Image data via serial port of my PC
and to display at the fastest rate possible so that we can test our
camera easily presently we are doing it using GPRS, I am using TCP
functions of LabView but its very slow due to Telco problems, data size
of each Image will be around 5KB!.Please suggest me on this.Thank you
in advance!
Have you used a serial communication with LabVIEW before?  I guess You will be getting  ascii values via your  com port(Select proper com port,Use Max for this purpose).Does your camera support LabVIEW? If yes than how much have you progressed?What is your application? Can you give us more information regarding the camera?PS: JLV beat me to it.Please answer his questions  tooMessage Edited by muks on 08-09-2008 07:19 AM
cschneider
2008-08-09 21:10:04 UTC
Permalink
So, could you please again specify your problem? You said you know how to get data out of your data logger, you have the commands you have to send by serial communication to get the data logger to transfer images, and you know the serial port properties like 9600 baud...so: where's the point? You don't get an image out, but why? You get unreadable data? No data? Christian
Hosangadi
2008-08-09 23:40:05 UTC
Permalink
<a href="../view_profile?user.id=81609" class="auth_text" style="font-weight: bold;" target="_blank"> cschneider,</a> Problem is in receiving data in PC using labiew via serial porrt, I used advanced serial read/write.vi but I am not getting any data...eventhough my datalogger sends image data....also for your information I need not issue any command frm my&nbsp; PC to datalogger to get the ?Image as you specified in your post....I think you have not understood my previous posts....kindly go through once again...thanks anyways<a href="../view_profile?user.id=81609" class="auth_text" style="font-weight: bold;" target="_blank"> </a>
Ravens Fan
2008-08-10 00:40:05 UTC
Permalink
If you open up Hyperterminal, do you see any data coming in?&nbsp; Are you sure you are using the right kind of cable whether it is a straight through cable or null modem?
Try using Hyperterminal to debug the communications first.&nbsp; Once you have it working there, and&nbsp;you know you have the right kind of cable and the communication settings correct, then you can use that information to get the LabVIEW serial read/write VI's working.
Dennis Knutson
2008-08-10 00:40:05 UTC
Permalink
If the logger is constanly streaming data and the serial example does not work, then you have a problem with the com port settings or you are using the wrong cable. The advanced serial example may not be the best example to use either since it expects data to be terminated. I would recomend that you first try getting data with Hyperterminal before trying to write any LabVIEW code. Then you can do something like putting a VISA Bytes at Serial Port/VISA Read in a loop.
If you were using TCP/IP before and found that slow, you'll probably find that the serial connection is going to much much slower than that.
Hosangadi
2008-08-10 00:40:05 UTC
Permalink
I tried sending a simple"Hello world" string and I could recieve the data on Hyperterminal with same cable and communication port setting, I have not used TCP&nbsp; directly I used GPRS to transfer data that is why it was slow, I think serial port will be faster than GPRS, my logger doesnt have a direct TCP connection.
Dennis Knutson
2008-08-10 04:40:06 UTC
Permalink
You tried sending the 'hello string' from what to what? From the pc back to itself? What was suggested was to test the video capture with Hyperterminal. Unless you can get something from the logger in Hyperterminal, you have not tested anything.
Hosangadi
2008-08-10 05:10:05 UTC
Permalink
I have sent Hello World string from my logger to PC and received it&nbsp; in both hyperterminal also in AdvancedSerialRead.vi!!! I have problem in receiving Image data only
Dennis Knutson
2008-08-10 05:10:05 UTC
Permalink
Exactly what kind of problem? Do you not get anything in Hyperterminal? If that's the case, then there would seem to be some setting of the logger that is not being done? You have not mentioned the make and model of the logger or provided any details such as a programming manual. Have you contacted the vendor about the serial problem. It does not sound like a LabVIEW problem.
Continue reading on narkive:
Loading...