-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manipulate colormap, contrast, brightness & window position #47
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this section
@@ -104,13 +112,24 @@ int main(int argc, char** argv) | |||
if (_fps) | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The keycodes should be defined as constants (no magic numbers)
@@ -22,11 +22,13 @@ void handle_sig(int sig) { | |||
} | |||
|
|||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cont
is normalize elsewhere. Likewise bright
should be brightness
Mat frame_g8, frame_g16; // Transient Mat containers for processing | ||
|
||
if(cont == 0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tabs
char c = waitKey(10); | ||
if (c == 's') { | ||
namedWindow("SeekThermal"); | ||
moveWindow("SeekThermal", x,y); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Processing these events should be handled in a dedicated function to separate out those concerns.
@@ -66,7 +69,12 @@ int main(int argc, char** argv) | |||
args::ValueFlag<int> _colormap(parser, "colormap", "Color Map - number between 0 and 12", {'c', "colormap"}); | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).