Manipulate colormap, contrast, brightness & window position#47
Manipulate colormap, contrast, brightness & window position#47rsend wants to merge 5 commits intoOpenThermal:masterfrom
Conversation
| Note that in this case, "+" means Shift + "=" and "-" is just the normal "-" key. The Numpad "+" and "-" return different scan codes so don't work at this time. | ||
|
|
||
| ### Window position | ||
| At least on Ubuntu (will check Debian later) the arrow keys allow moving the window position. Scancodes are different for each platform (supposedly for different renderers even), so this may not work on your environment. |
There was a problem hiding this comment.
We don't want functionality to be tied to one OS. Could you investigate further if these can be made stable across multiple systems
| ### Window position | ||
| At least on Ubuntu (will check Debian later) the arrow keys allow moving the window position. Scancodes are different for each platform (supposedly for different renderers even), so this may not work on your environment. | ||
|
|
||
| ## Feedback |
There was a problem hiding this comment.
Remove this section
| fps = args::get(_fps); | ||
| // Colormap int corresponding to enum: http://docs.opencv.org/3.2.0/d3/d50/group__imgproc__colormap.html | ||
| int colormap = -1; | ||
| // int colormap = -1; |
There was a problem hiding this comment.
remove commented code
| moveWindow("SeekThermal", x,y); | ||
| int c = waitKeyEx(5); | ||
| //std::cout << (int)c << std::endl; | ||
| if (c == 112) { |
There was a problem hiding this comment.
The keycodes should be defined as constants (no magic numbers)
|
|
||
| // Function to process a raw (corrected) seek frame | ||
| void process_frame(Mat &inframe, Mat &outframe, float scale, int colormap, int rotate) { | ||
| void process_frame(Mat &inframe, Mat &outframe, float scale, int colormap, int rotate, int cont, int bright) { |
There was a problem hiding this comment.
cont is normalize elsewhere. Likewise bright should be brightness
| void process_frame(Mat &inframe, Mat &outframe, float scale, int colormap, int rotate, int cont, int bright) { | ||
| Mat frame_g8, frame_g16; // Transient Mat containers for processing | ||
|
|
||
| if(cont == 0){ |
There was a problem hiding this comment.
Incorrect spacing, all the changes need to go through formatting to bring them in line with the established style
| //Constant contrast or auto-adjust | ||
| if(_normalize){ | ||
| if(_ffc) { | ||
| brightness=620000; |
| char c = waitKey(10); | ||
| if (c == 's') { | ||
| namedWindow("SeekThermal"); | ||
| moveWindow("SeekThermal", x,y); |
There was a problem hiding this comment.
This blocks the user from moving the window using their window manager. That doesn't seem reasonable.
| moveWindow("SeekThermal", x,y); | ||
| int c = waitKeyEx(5); | ||
| //std::cout << (int)c << std::endl; | ||
| if (c == 112) { |
There was a problem hiding this comment.
Processing these events should be handled in a dedicated function to separate out those concerns.
| args::ValueFlag<int> _rotate(parser, "rotate", "Rotation - 0, 90, 180 or 270 (default) degrees", {'r', "rotate"}); | ||
| args::ValueFlag<std::string> _camtype(parser, "camtype", "Seek Thermal Camera Model - seek or seekpro", {'t', "camtype"}); | ||
|
|
||
| args::ValueFlag<int> _normalize(parser, "normalize", "0 for normal normalization, 1-50 (ish) for custom contrast", {'n',"normalize"}); |
There was a problem hiding this comment.
normal normalization -> automatic normalization
|
I know this isn't very good code, but figured other people might find the functionality useful. I'm a hardware engineer (I don't code) and I needed this functionality, so I tried my best to add it. I'll see what I can do, but I'd be happy to take suggestions (particularly for the window moving and key code scanning). |
Hey, don't feel bad! Practicing is the best way to learn this stuff. My comments on the syntax don't detract from the functionality. In particular I think the fixed range mode is particularly useful and something we don't have. How about opening a narrower pull request just adding that functionality via command line parameters. I think there is an OpenCV function which does this a little more safely. https://docs.opencv.org/2.4/modules/core/doc/basic_structures.html#void%20Mat::convertTo(OutputArray%20m,%20int%20rtype,%20double%20alpha,%20double%20beta)%20const |
I created this so I can change the appearance of the output window on-the-fly. The colormap, brightness & contrast can be cycled through manually and the window position & size can be moved with the arrow or +/- keys (the arrows might need some work - I don't know how to make key scancode access generic).