03-25-2014 09:14 AM
03-25-2014 09:54 AM
I don't think you could do that string conversion efficiently. Your string will be an order of magnitude larger than your image, and will take much longer to send over tcp.
I would suggest converting the image to a string using JPEG or PNG compression, then sending that string over tcp. It takes a little work to convert it back on the other end, but it will be much faster that your method. If you really need it in this format, convert it on the receiving end.
Worst case scenario, convert the image to an array, then flatten the array to a string. You can easily convert back to an image on the other end, but there will be no compression.
Bruce
03-25-2014 12:14 PM
I tried the worst scenario, use the Flatten To JSON Function to convert the raw data 1d numeric array to comma seperated string, but it is so slow, that the frame rate drops to 0.8fps. I run the code on the NI 1774c target. When I delete the flatten to JSON module, it recovers to the normal frame rate 17fps. I even haven't send it through tcp.
It seems that converting image to string take a lot of time and I'm worry even the the JPEG compression won't help to accelerate it to 17fps.
03-25-2014 12:45 PM
I'm not sure, but I suspect the JSON conversion takes longer than standard convert to string.
I would try compressing to a JPEG string just to see how fast it is. You may not maintain your frame rate, but you will be closer, I think.
What size image is it? That can make a big difference. Do you need a high quality image sent back, or is it just for display? You can do a lot of JPEG compression if you don't need high quality.
Make sure you have two loops running in parallel. One should be doing the acquisition and putting it into a buffer. The other should be pulling from the buffer, compressing, and sending. This will maximize your rate.
Bruce
03-25-2014 01:09 PM
BruceAmmons wrote:Worst case scenario, convert the image to an array, then flatten the array to a string. You can easily convert back to an image on the other end, but there will be no compression.
Good advice in the post, Bruce, but I wanted to also make you aware that if you grab the latest Vision Acquisition or Vision installer, we now have an "Image to EDVR" (External Data Value Reference) VI that lets you access the array data inside a Vision image directly in-place without the memory allocations and copies of Image-to-Array.
Eric