Y16 support on Windows in OpenCV (e.g. for PT)

1,188 views
Skip to first unread message

Josh Veitch-Michaelis

unread,
Sep 14, 2018, 5:59:11 AM9/14/18
to Flir Lepton
Hi everyone,

This may be useful for some of you here - I've submitted a pull request to OpenCV adding Y16 support in Windows/DirectShow. TLDR you can now capture raw thermal data without needing modified versions of libuvc and/or switching drivers. My motivation was to get images out of a FLIR Boson, but it should also work with the PureThermal or any other machine vision camera that supports Y16.

It's not been merged yet, but if you fancy trying it, it'd be useful to see if there are any bugs.  The easiest way to test is to clone my fork and checkout the appropriate branch: https://github.com/jveitchmichaelis/opencv.git

To use it you need to force OpenCV to use dshow:

cv::VideoCapture cap(0 + cv::CAP_DSHOW)

then set the options:

cap.set(cv::CAP_PROP_FOURCC, cv::VideoWriter::fourcc('Y','1','6',' '));
cap.set(cv::CAP_PROP_CONVERT_RGB, true);

You need to turn of RGB conversion. This is more of a standards compliance thing with OpenCV, image capture devices should return RGB images by default. If you don't do this, you'll get a grey RGB image (which is just an 8-bit scaled version of the raw data).

Happy imaging!

Kurt Kiefer

unread,
Sep 14, 2018, 5:08:15 PM9/14/18
to Flir Lepton
Josh,

This is really cool. It's exciting to see the VideoCapture driver getting love.

Now it looks like it's time for to re-try a modern version of VideoCapture and publish some new example code. Apparently V4L2 now has Y16 support, so we can do radiometry with straight OpenCV.

Kurt

Marty Falatic

unread,
Jan 7, 2019, 5:25:51 AM1/7/19
to Flir Lepton
I've been trying to find a way to get raw 16-bit data out today using OpenCV, and here you've gotten support merged in! :-D

Your note above says "You need to turn of RGB conversion." so I'm a bit confused as to which way that typo falls (of->on or of->off) and how it affects that setting.

Seems the only way I can actually get 16-bit data out is to use `cap.set(cv::CAP_PROP_CONVERT_RGB, false);`

Note I'm doing this in Python 3.7. It works (in that I'm seeing 16-bit data for once, versus 8-bit or RGB), though I've no idea if it's producing valid radiometry yet...

Marty Falatic

unread,
Jan 7, 2019, 5:54:30 AM1/7/19
to Flir Lepton
Did I speak too soon? Is the Y16 data actually radiometric (considering the 3.5 on the PT2)? Does this help with reading that in directly?
Reply all
Reply to author
Forward
0 new messages