From 07ec7dfc1f4989dac09f0e695f8486851c6c9f01 Mon Sep 17 00:00:00 2001 From: Rafael Send Date: Wed, 18 Dec 2019 14:00:50 -0800 Subject: [PATCH 1/5] wasd brightness / contrast --- examples/seek_viewer.cpp | 50 ++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/examples/seek_viewer.cpp b/examples/seek_viewer.cpp index f2f019c..40b0fcb 100644 --- a/examples/seek_viewer.cpp +++ b/examples/seek_viewer.cpp @@ -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) { Mat frame_g8, frame_g16; // Transient Mat containers for processing - + if(cont == 0){ normalize(inframe, frame_g16, 0, 65535, NORM_MINMAX); - +} else{ +frame_g16=(inframe*cont)-bright; +} // Convert seek CV_16UC1 to CV_8UC1 frame_g16.convertTo(frame_g8, CV_8UC1, 1.0/256.0 ); @@ -66,6 +68,10 @@ int main(int argc, char** argv) args::ValueFlag _colormap(parser, "colormap", "Color Map - number between 0 and 12", {'c', "colormap"}); args::ValueFlag _rotate(parser, "rotate", "Rotation - 0, 90, 180 or 270 (default) degrees", {'r', "rotate"}); args::ValueFlag _camtype(parser, "camtype", "Seek Thermal Camera Model - seek or seekpro", {'t', "camtype"}); + args::ValueFlag _normalize(parser, "normalize", "0 for normal normalization, 1-50 (ish) for custom contrast", {'n',"normalize"}); + int colormap=0; + int brightness=0; + int normalize=0; // Parse arguments try @@ -104,13 +110,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; if (_colormap) colormap = args::get(_colormap); // Rotate default is landscape view to match camera logo/markings + //Constant contrast or auto-adjust + if(_normalize){ + if(_ffc) { + brightness=620000; + normalize=40; + } else{ + brightness=590000; + normalize=40; + } + } int rotate = 270; if (_rotate) rotate = args::get(_rotate); + // Register signals signal(SIGINT, handle_sig); @@ -140,7 +157,7 @@ int main(int argc, char** argv) return -1; } - process_frame(seekframe, outframe, scale, colormap, rotate); + process_frame(seekframe, outframe, scale, colormap, rotate, normalize, brightness); // Create an output object, if output specified then setup the pipeline unless output is set to 'window' VideoWriter writer; @@ -164,17 +181,32 @@ int main(int argc, char** argv) } // Retrieve frame from seek and process - process_frame(seekframe, outframe, scale, colormap, rotate); + process_frame(seekframe, outframe, scale, colormap, rotate, normalize, brightness); if (output == "window") { imshow("SeekThermal", outframe); - char c = waitKey(10); - if (c == 's') { + char c = waitKey(5)&0xFF; + if (c == 112) { waitKey(0); } - } else { + else if (c ==119 && _normalize){ + normalize++; + } else if (c ==115 && _normalize){ + normalize--; + } else if (c == 100 && _normalize){ + brightness+=5000; + }else if (c == 97 && _normalize){ + brightness-=5000; + }else if(c == 99){ + if(colormap<12){ + colormap++; + }else{ + colormap=0; + } + }else { writer << outframe; } + } } std::cout << "Break signal detected, exiting" << std::endl; From 0aca3c0cefe3fb4a6b6dfd958b483263afc21d9b Mon Sep 17 00:00:00 2001 From: Rafael Send Date: Wed, 18 Dec 2019 15:19:17 -0800 Subject: [PATCH 2/5] Add rotation, update Readme --- README.md | 17 +++++++++++++++++ examples/seek_viewer.cpp | 14 +++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b418a7f..a212be3 100644 --- a/README.md +++ b/README.md @@ -149,3 +149,20 @@ seek_viewer -t seek -F seek_ffc.png seek_test_pro seekpro_ffc.png seek_viewer -t seekpro -F seekpro_ffc.png ``` +## Added functionality +### Color map selecting +Cycle through all 12 color maps by pressing 'c'. Black and white is not a standard "colormap" but it is preseved at the 0th position, for a total of 13 possible maps. + +###Rotating +Pressing 'r' will change the orientation (4 possible) + +### Brightness & contrast +By providing the '-n 1' command line switch, brightness and contrast are no longer adjusted dynamically. + +'w' will increase the contast +'s' will decrease the contrast +'a' will decrease the brightness +'d' will increase the brightness + +This function provides quite granular control, but this also means brightness has to be tweaked to match for each adjustment to contrast. +It is useful for having the field of vision not suddendly change in appearance completely when a hot or cold object is viewed. diff --git a/examples/seek_viewer.cpp b/examples/seek_viewer.cpp index 40b0fcb..31cef1e 100644 --- a/examples/seek_viewer.cpp +++ b/examples/seek_viewer.cpp @@ -49,8 +49,8 @@ frame_g16=(inframe*cont)-bright; resize(frame_g8, frame_g8, Size(), scale, scale, INTER_LINEAR); // Apply colormap: http://docs.opencv.org/3.2.0/d3/d50/group__imgproc__colormap.html#ga9a805d8262bcbe273f16be9ea2055a65 - if (colormap != -1) { - applyColorMap(frame_g8, outframe, colormap); + if (colormap != 0) { + applyColorMap(frame_g8, outframe, colormap-1); } else { cv::cvtColor(frame_g8, outframe, cv::COLOR_GRAY2BGR); } @@ -203,7 +203,15 @@ int main(int argc, char** argv) }else{ colormap=0; } - }else { + }else if(c==114){ + if(rotate==270){ + rotate=0; + } + else{ + rotate+=90; + } + } + else { writer << outframe; } } From 5b176e63e4ade88d072832841d9722ea3688573f Mon Sep 17 00:00:00 2001 From: Rafael Send Date: Wed, 18 Dec 2019 15:20:08 -0800 Subject: [PATCH 3/5] Update Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a212be3..cb11baa 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ seek_viewer -t seekpro -F seekpro_ffc.png ### Color map selecting Cycle through all 12 color maps by pressing 'c'. Black and white is not a standard "colormap" but it is preseved at the 0th position, for a total of 13 possible maps. -###Rotating +### Rotating Pressing 'r' will change the orientation (4 possible) ### Brightness & contrast From d8d98cfdfac4eb53c55ee27211177d6ded029af8 Mon Sep 17 00:00:00 2001 From: linaro Date: Thu, 19 Dec 2019 06:16:29 +0000 Subject: [PATCH 4/5] Scaling --- examples/seek_viewer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/seek_viewer.cpp b/examples/seek_viewer.cpp index 31cef1e..68be556 100644 --- a/examples/seek_viewer.cpp +++ b/examples/seek_viewer.cpp @@ -210,8 +210,11 @@ int main(int argc, char** argv) else{ rotate+=90; } - } - else { + }else if(c==43){ + scale +=0.05; + }else if(c==45){ + scale -=0.05; + }else { writer << outframe; } } From 427f8e5389f2bcedcff9beef3362233f03f456ec Mon Sep 17 00:00:00 2001 From: Rafael Send Date: Thu, 19 Dec 2019 15:29:00 -0800 Subject: [PATCH 5/5] Arrow keys move window --- README.md | 13 +++++++++++++ examples/seek_viewer.cpp | 27 ++++++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cb11baa..70f002f 100644 --- a/README.md +++ b/README.md @@ -160,9 +160,22 @@ Pressing 'r' will change the orientation (4 possible) By providing the '-n 1' command line switch, brightness and contrast are no longer adjusted dynamically. 'w' will increase the contast + 's' will decrease the contrast + 'a' will decrease the brightness + 'd' will increase the brightness This function provides quite granular control, but this also means brightness has to be tweaked to match for each adjustment to contrast. It is useful for having the field of vision not suddendly change in appearance completely when a hot or cold object is viewed. + +### Scaling +One can also adjust the size of the output (scaling value) by pressing + or -. +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. + +## Feedback +I've started a thread about this updated version on EEVBlog, please comment for questions / issues: https://www.eevblog.com/forum/thermal-imaging/slightly-updated-libseek-thermal-(keyboard-interface)/ diff --git a/examples/seek_viewer.cpp b/examples/seek_viewer.cpp index 68be556..3167f9e 100644 --- a/examples/seek_viewer.cpp +++ b/examples/seek_viewer.cpp @@ -58,7 +58,8 @@ frame_g16=(inframe*cont)-bright; int main(int argc, char** argv) { - // Setup arguments for parser + +// Setup arguments for parser args::ArgumentParser parser("Seek Thermal Viewer"); args::HelpFlag help(parser, "help", "Display this help menu", {'h', "help"}); args::ValueFlag _output(parser, "output", "Output Stream - name of the video file to write", {'o', "output"}); @@ -72,7 +73,8 @@ int main(int argc, char** argv) int colormap=0; int brightness=0; int normalize=0; - + int x=100; + int y=100; // Parse arguments try { @@ -185,7 +187,10 @@ int main(int argc, char** argv) if (output == "window") { imshow("SeekThermal", outframe); - char c = waitKey(5)&0xFF; + namedWindow("SeekThermal"); + moveWindow("SeekThermal", x,y); + int c = waitKeyEx(5); + //std::cout << (int)c << std::endl; if (c == 112) { waitKey(0); } @@ -193,10 +198,10 @@ int main(int argc, char** argv) normalize++; } else if (c ==115 && _normalize){ normalize--; - } else if (c == 100 && _normalize){ - brightness+=5000; - }else if (c == 97 && _normalize){ + } else if (c == 100 && _normalize){ // normally 100 brightness-=5000; + }else if (c == 97 && _normalize){ //normally 97 + brightness+=5000; }else if(c == 99){ if(colormap<12){ colormap++; @@ -210,10 +215,18 @@ int main(int argc, char** argv) else{ rotate+=90; } - }else if(c==43){ + }else if(c==65579){ scale +=0.05; }else if(c==45){ scale -=0.05; + }else if(c==65362){ + y-=10; + }else if(c==65364){ + y+=10; + }else if(c==65363){ + x+=10; + }else if(c==65361){ + x-=10; }else { writer << outframe; }