hello,
i'm trying to get color disparity map not NVCom but C++ code.
when i use a function 'writePgmFile()', i see '.pgm' images with gray-color.
and a result mat of 'toOpenCVImage()' function is 2-depth.
would you plz give directions to save color disparity map?
thanks.
how to save color disparity map from 'ImageTransfer' ?
-
- Posts: 117
- Joined: Mon Mar 25, 2019 1:12 pm
Re: how to save color disparity map from 'ImageTransfer' ?
If you are trying to replicate the color coding of NVCom, you can download the full source code from our download page. The relevant class is in the files:
nerian-vision-software-9_0_5-src/nvcom/helpers/colcoder.*
This class applies color coding to an OpenCV image, which you can get from the toOpenCVImage() method.
OpenCV itself also provides a similar functionality. Please have a look at this article:
https://docs.opencv.org/4.x/d3/d50/group__imgproc__colormap.html
nerian-vision-software-9_0_5-src/nvcom/helpers/colcoder.*
This class applies color coding to an OpenCV image, which you can get from the toOpenCVImage() method.
OpenCV itself also provides a similar functionality. Please have a look at this article:
https://docs.opencv.org/4.x/d3/d50/group__imgproc__colormap.html
Re: how to save color disparity map from 'ImageTransfer' ?
thanks for quick reply. it is very helpful.
Re: how to save color disparity map from 'ImageTransfer' ?
Hello,
is there a way to use the functionality of nvcom/helpers/colorcoder.cpp with Python? More precisely, I would like to know how to apply colormap_rainbow to disparity map with Python just like in the API review page (which uses for example rainbow color map and sets invalid pixels to gray). I tried with cv2.applyColorMap() but it does not set the invalid pixels to gray like in the API.
is there a way to use the functionality of nvcom/helpers/colorcoder.cpp with Python? More precisely, I would like to know how to apply colormap_rainbow to disparity map with Python just like in the API review page (which uses for example rainbow color map and sets invalid pixels to gray). I tried with cv2.applyColorMap() but it does not set the invalid pixels to gray like in the API.
Last edited by fdirman on Tue Apr 05, 2022 1:26 pm, edited 1 time in total.
-
- Posts: 117
- Joined: Mon Mar 25, 2019 1:12 pm
Re: how to save color disparity map from 'ImageTransfer' ?
For the ColorCoder class there is unfortunately no python binding. Given the small size of this class, the best option would be to re-create this class in python. All it does is, it linearly interpolates between the colors in the color table.
There are some optimizations being done, like pre-computing all the colors for 8-bit and 16-bit images, but these optimizations are not necessary if performance is not super critical.
There are some optimizations being done, like pre-computing all the colors for 8-bit and 16-bit images, but these optimizations are not necessary if performance is not super critical.