From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from the specific binary file

Hallo,
I received binary file with specific format and I need to read images from this file, but I have no idea how to do it.
In this binary, images from the camera and settings are saved. I need to read just the images and time between them. I don't know how to extract this.
Thank you very much for your help.

There is a binary stucture.

Saving images *.bvg

 

Head of file (1024 bytes)

 

            Size of the head file : U32

            Size of the head of the image :U32

            Size od the picture with head: U32

            Number of images: U32

            x-size of images, in pixels: U32

            y-size of images, in pixels: U32

Type of the images: U32

            0….Grayscale(U8)

            1….Grayscale(I16)

            2….Grayscale(SGL)

            3….Complex(CSG)

            4….RGB(U36)

            5….HSL(U8)

            6….RGB(U64)

 

Time of the picture taking:

·         Length of the string: U32

·         String (day.month.year   hours:minutes:seconds)

Camera settings:

·         Exposure: U32

·         Binning: U32

·         ROI X: U32

·         ROI Y: U32

·         ROI Width: U32

·         ROI Height: U32

·         Bit depth: U32

·         Colour: U32

0….Grayscale

1….RGB

 

 

Head of the image (128 bytes):

            Time from the previous image, in seconds: DBL

 

Image:

            x-axis size of image: U32

            y-axis size of image: U32

            matrix of intensity: it depands on image type

 

 

 

 


0 Kudos
Message 1 of 5
(2,686 Views)
This does not seem very difficult. Just read the file as one big string, then typcast the parts according to the pattern given.
 
(One complication could be byte order. Do you know if the file is big endian or little endian?)
 
Can you attach a typical file so we can try? 🙂
0 Kudos
Message 2 of 5
(2,677 Views)
It is "native, host order".

There is the file

http://fry.mstu.cz/pic.bvg

I cannot upload it, it is too big (5.27MB)

Thank you very much for your help.

0 Kudos
Message 3 of 5
(2,669 Views)

OK, what is your LabVIEW version? For pre-8.0 you need to do the byte spwapping manually, while newer versions have it built-in as an option for the file read and flatten/unflatten tools, etc.

Attached is a very simple example that should point you in the right direction and get you going (LabVIEW 8.0). Modify as needed.

I read the 1024 byte header as U32 array, then read the 128 byte image header, then read the first image frame using the sizes from the header and the image type from the example file (U8 greyscale). Many additions are needed to e.g. automatically deal with different image types, etc.

0 Kudos
Message 4 of 5
(2,643 Views)
Thank you very much for your help, now I understand how it works.

Tomas
0 Kudos
Message 5 of 5
(2,589 Views)