LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transfer byte array to create an image using TCP/IP

I have a LINUX based target system to which i send some commands (using TCP Write VI) via TCP/IP. The target system gives  an array (2D) of Bytes which represent a Picture Frame.  I need to create a grayscale image from this array of bytes and the dimension of camera is: 752 X 480.

 

But instead of getting a grayscale image, I am getting a binary image with Image Pixels(U8) with 0,1,2,3 values etc resulting into a dark image.

Can someone suggest why I am getting a dark black image instead of a  grayscale Image?

0 Kudos
Message 1 of 8
(3,033 Views)

Can you show the code that is sending the image? Are you sure you are converting the data correctly?

 

Also, in the first TCP read, you are reading 1024 bytes to get the message length.. Are you sure that is correct? 1024 Bytes to specify the message length seems excessive... 

0 Kudos
Message 2 of 8
(3,018 Views)

The target system has a camera fixed in it. So when the specific commands "grab_frame" is sent to the target system, it reads an Array of 2D Bytes representing a Picture frame. The target system does specific functions according to it's corresponding commands. Therefore, I don't have the internal code how the target system is designed to execute the commands.

Yes 1024 Bytes is excessive. I have tried with 4 Bytes too, but it gives me the same problem.

0 Kudos
Message 3 of 8
(2,995 Views)

I agree with Paul Ross.  Most "size" parameters are 4-byte Integers, so if you changed the 1024 for the first TCP Read to 4, it might suddenly work (read the Help on TCP Read).  You didn't say, but I would have expected the (truncated, why?) Error Line would have given a Timeout Error in the "Error Out" indicator.

 

Bob Schor

0 Kudos
Message 4 of 8
(2,990 Views)

Where are you getting the 1024 or 4 Bytes from? Is there some documentation with the target system that describes the message packet? If the message length header is 4 bytes, and you are reading 1024, you are going to be missing some of the data in your message because you already read that data and just discarded it when you did the first read. 

 

Beyond that, it is going to be difficult for anyone here to give you much help without more information - what is the hardware? Is it some off the shelf item that maybe someone else here has used? Can you share the documentation? My guess is that message packet has some defined format, and you are not parsing it into the image data correctly. 

 

 

0 Kudos
Message 5 of 8
(2,985 Views)

@Bob_Schor wrote:

I agree with Paul Ross.  Most "size" parameters are 4-byte Integers, so if you changed the 1024 for the first TCP Read to 4, it might suddenly work (read the Help on TCP Read).  You didn't say, but I would have expected the (truncated, why?) Error Line would have given a Timeout Error in the "Error Out" indicator.

 

Bob Schor


I have checked using with 4 Bytes too, same Problem. Yes, you are right. I am getting timeout error with error Code:66

0 Kudos
Message 6 of 8
(2,972 Views)

@paul.r wrote:

Where are you getting the 1024 or 4 Bytes from? Is there some documentation with the target system that describes the message packet? If the message length header is 4 bytes, and you are reading 1024, you are going to be missing some of the data in your message because you already read that data and just discarded it when you did the first read. 

 

Beyond that, it is going to be difficult for anyone here to give you much help without more information - what is the hardware? Is it some off the shelf item that maybe someone else here has used? Can you share the documentation? My guess is that message packet has some defined format, and you are not parsing it into the image data correctly. 

 

 


I will check with the documentation about the message header. Thanks for the valuable Information.  However, Please check the attached Image ,which I have got from Wireshark.

0 Kudos
Message 7 of 8
(2,969 Views)

I'm guessing that if you thought that picture had information relevant to the issue, we have issues beyond LabVIEW to explore...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 8
(2,957 Views)