92es / Thermal-Camera-Redux

Topdon TC001 (and clone) thermal camera app to read and display live and offline thermal data
38 stars 9 forks source link

File type of recorded video #2

Closed kchiwhane closed 3 months ago

kchiwhane commented 3 months ago

I notice that the video file output of this drone is .avi. Does this camera have any capacity to output radiometric jpeg or .tiff or anything similar which has thermal data embedded into the images?

92es commented 3 months ago

The application has the ability to take stills. The stills consists of 2 file formats.

The first file is a ( .png ) image which composites the entire onscreen image ( video, thermal, text, menus, plots and graphics information ). This static image can not be deconstructed into the original components ( thermal data, video frame, graphics elements ). It can be displayed by any image viewer supporting the PNG format.

The second ( .raw ) file contains the raw data from the camera which includes 2 sub frames. The first sub frame contains the thermal data in Kelvin ( 1 temp per pixel ) and the second sub frame contains the raw monochrome video image ( no colormaps applied ).

Both sub frames are 192x256 pixels, but the monochrome scale in the 2nd subframe does NOT directly correspond to the thermal data. The camera adds image enhancement filtering alterations to the 2nd sub frame, thus altering the original mapping.

The ( .raw ) image information is used for offline post-processing mode so the user can reload the raw data and apply any of the apps scaling, filtering, rotation, colormaps, temp widgets, rulers, plots, etc. features to post analyze the data and optionally take new composited ( .png ) stills with different data perspectives.

The ( .raw ) file could conceivably be used to composite and output other image formats because the ( .raw ) format is NOT lossy like the JPEG format and other lossy formats.

Currently supported OpenCV formats

Currently, the following file formats are supported in OpenCV:

Windows bitmaps - *.bmp, *.dib (always supported)
JPEG files - *.jpeg, *.jpg, *.jpe (see the Note section)
JPEG 2000 files - *.jp2 (see the Note section)
Portable Network Graphics - *.png (see the Note section)
WebP - *.webp (see the Note section)
AVIF - *.avif (see the Note section)
Portable image format - *.pbm, *.pgm, *.ppm *.pxm, *.pnm (always supported)
PFM files - *.pfm (see the Note section)
Sun rasters - *.sr, *.ras (always supported)
TIFF files - *.tiff, *.tif (see the Note section)
OpenEXR Image files - *.exr (see the Note section)
Radiance HDR - *.hdr, *.pic (always supported)
Raster and Vector geospatial data supported by GDAL (see the Note section)

Other formats could be supported with different libraries.

Hope this helps.

92es commented 3 months ago

After doing a quick search, I found this:

"... After a bit of searching, it seems like Radiometric JPEG images are proprietary to each manufacturer, so you need the manufacturer's software to extract the numeric data. ..."

R-JPEG may not be a standardized format.

kchiwhane commented 3 months ago

If I want to analyze thermal data from a series of images, could I only take, for example, .TIFF stills?

Currently I extract frames from a video but to me this seems like I can only take pictures if I want thermal data associated with my images.

92es commented 3 months ago

When you extract data from the thermal camera, you have to guarantee the data is UNSCATHED and returned in a consistent, valid, known format. You also have to make sure you are extracting all the data, not just the video image.

If you use the OpenCV library, the back end that presents the data to the application can return the data in a lossy format. Lossy formats corrupts the thermal data so it is useless for analysis other than looking at eye candy pictures.

My app makes sure the back end returns the data in a valid format which is stored in row-major unsigned shorts ( 2-bytes / 16-bits per pixel ). Forex, my app won't work as a VirtualBox client because VirtualBox changes the image format passed to the client OS from the USB camera attached to the host OS.

The numeric data in the unsigned shorts is different for the thermal frame and the image frames. The thermal frame's unsigned shorts contain encoded Kelvin values and the image frame contains encoded CLUT indexes. Kelvin value ranges != CLUT index ranges so they have to be treated independently.

If you are using other formats, the format will have to be lossless and you will have to know how the data has been encoded/stored to extract it. If you are missing either of those pieces of information, you won't be able to accomplish your task.

I do not know how or if thermal data can be encoded in TIFF formats. Do you have any links defining the storage format for thermal TIFF storage ???

92es commented 3 months ago

Here is an example of the video and thermal frames (with a colormap applied to both).

You can see the data is different between the 2.

Depending on the API, you could just pull the top image from the camera ( sans the digital temp graphic overlays ).

If your TIFF still just contains the image information, you can not go backwards to the thermal frame data.

GITHUB_VIDEO_THERMAL

kchiwhane commented 3 months ago

I do not know how or if thermal data can be encoded in TIFF formats. Do you have any links defining the storage format for thermal TIFF storage ???

You are correct. I originally thought thermal data could be encoded in TIFF formats but this is not possible as explained in this link.

Thanks for the replies.

92es commented 3 months ago

So it appears they are suggesting TIFF because of its lossless compression (of which there are other lossless formats) for thermal data and JPEG for lossy compression of the image.

There doesn't appear to be a ubiquitous storage format standard yet for the industry.

Maybe I should submit mine as the de-facto standard because it is already in such wide use by tens of people ??? =)

92es commented 3 months ago

Question answered.