LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hex data to file jpg

Hi praveen,

 

your "saved file" only has some errors in the file, I could open it with IrfanVIEW and save it as PNG:

check.png

(Looks like a typical office equipment. :D)

Those "colored bars" are typical for data errors in JPG images: JPG stores data with a minimum block size of 8 pixels. With an encoding error the JPG decompression shows those artefacts…

 

So you need to make sure there are no errors in transmission of your JPG data!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 21 of 27
(970 Views)

Dear GerdW,

 

😄 Happy to see the result.

 

(Looks like a typical office equipment. Smiley Very Happy)

Yes, yes. Smiley LOL

 

Thank you for your efforts and guidance. By the way, what is the issue in the .jpg file?

Is that saved in correct format?? 

 

your "saved file" only has some errors in the file, I could open it with IrfanVIEW and save it as PNG:

It will be helpful if you say the error. IrfanView opens the file. In my case, My objective is to save the images automatically to the hard disk via LabVIEW software. 

 

Great help. 🙂

 

-Praveen

0 Kudos
Message 22 of 27
(964 Views)

Hi praveen,

 

It will be helpful if you say the error. IrfanView opens the file.

I can't "say the error" - I can only guess there are some transmission errors between your device and your computer leading to invalid data in the JPEG stream.

Some software is more strict about such invalid data (like GIMP being unable to open your JPG file), other is more tolerant like IrfanVIEW.

 

So I repeat: check for any transmission errors between your device and your computer!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 23 of 27
(957 Views)

Dear GredW,

 

FIne. I checked the data from the camera and the count is correct need to verify with the checksum. Thank you once again.

 

-Praveen

0 Kudos
Message 24 of 27
(954 Views)

Dear GredW,

 

Thank you very much for your great guidance. I got my result.

 

The thing is I need to order the data from FFD8 to FFD9 that the image info. Actually, the camera sent the header as well as the checksum. Those are not needed.

 

I am just posting this coz someone can use this info in future.

 

Thank you once again.

 

-Praveen

0 Kudos
Message 25 of 27
(939 Views)

Hi Praveen, 
Right now I,m facing the same problem you faced. I have hexadecimal text file. with matlab I can convert this hexadecimal file into RGB image. But I need to do it in LABView. If you have any example vi, Kindly share.

I attached matlab code below,

fid = fopen('hexfile.txt', 'r');
bindata = fscanf(fid, '%2x');
fclose(fid);
fidimage = fopen('hexdata.jpg', 'w');
fwrite(fidimage, bindata); %save bytes to jpeg file
fclose(fidimage);
img = imread('hexdata.jpg');
imshow(img);

bindata ( 27819*1)
img (600*800*3)
 
I wanted to do exact thing in labview.



Thanks.
Rajkumar

0 Kudos
Message 26 of 27
(534 Views)

Hi Rajkumar,

 

read the text file, convert each pair of chars to U8 value, write the binary file:

GerdW_0-1678296329849.png

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 27 of 27
(517 Views)