From 0ac67c7bcba46522726f18a35e2977dc7f90d40b Mon Sep 17 00:00:00 2001 From: Myzhar Date: Thu, 21 Sep 2017 15:03:41 +0200 Subject: [PATCH] Add test_tracker to verify bbb_life_tracker --- CMakeLists.txt | 5 +- bbb_life_tracker/CMakeLists.txt | 26 ++-- bbb_life_tracker/bbb_life_tracker.cpp | 124 +++++++++++++----- .../flir_tracker}/src/Palettes.cpp | 32 ++--- .../flir_tracker/src/flir_tracker.cpp | 93 ++++++++++++- bbb_life_tracker/test_tracker.cpp | 65 +++++++++ grabber_lib/include/Palettes.h | 23 ---- opencv_demo/opencv_demo.cpp | 2 +- 8 files changed, 282 insertions(+), 88 deletions(-) rename {grabber_lib => bbb_life_tracker/flir_tracker}/src/Palettes.cpp (79%) create mode 100644 bbb_life_tracker/test_tracker.cpp delete mode 100644 grabber_lib/include/Palettes.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 357cd7a..3ae1e47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,12 +10,13 @@ set(CMAKE_DEBUG_POSTFIX "_d") set (CMAKE_CXX_STANDARD 11) ######################################################### -# Library source code -add_subdirectory (grabber_lib) # bbb_life_tracker add_subdirectory (bbb_life_tracker) +# Library source code +add_subdirectory (grabber_lib) + # OpenCV demo add_subdirectory (opencv_demo) diff --git a/bbb_life_tracker/CMakeLists.txt b/bbb_life_tracker/CMakeLists.txt index f5bc1c2..bbb2c1e 100644 --- a/bbb_life_tracker/CMakeLists.txt +++ b/bbb_life_tracker/CMakeLists.txt @@ -15,9 +15,9 @@ set(LIB_GSTREAMER ${GSTREAMER_LIBRARIES} ${GSTREAMER_APP_LIBRARIES} ######################################################### # SOURCES -file(GLOB_RECURSE DEMO_SRC *.c *.cpp) -# HEADERS -file(GLOB_RECURSE DEMO_HDR *.h *.hpp) +set(TRK_SRC ${CMAKE_CURRENT_SOURCE_DIR}/flir_tracker/src/flir_tracker.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/flir_tracker/src/Palettes.cpp ) +set(ENC_SRC ${CMAKE_CURRENT_SOURCE_DIR}/videoEncoder/src/videoEncoder.cpp ) ######################################################### include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/videoEncoder/include @@ -27,11 +27,19 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/videoEncoder/include ${CMAKE_CURRENT_SOURCE_DIR}/flir_tracker/include ) - -add_executable (bbb_life_tracker ${DEMO_SRC} ) -target_link_libraries (bbb_life_tracker LINK_PUBLIC - lepton3_grabber +add_executable (test_tracker test_tracker.cpp ${TRK_SRC}) +target_link_libraries (test_tracker LINK_PUBLIC ${LIB_GSTREAMER} - opencv_core - opencv_highgui + opencv_core + opencv_highgui + opencv_imgproc) + +add_executable (bbb_life_tracker bbb_life_tracker.cpp ${ENC_SRC} ${TRK_SRC} ) +target_link_libraries (bbb_life_tracker LINK_PUBLIC + lepton3_grabber + ${LIB_GSTREAMER} + opencv_core + opencv_highgui opencv_imgproc) + + diff --git a/bbb_life_tracker/bbb_life_tracker.cpp b/bbb_life_tracker/bbb_life_tracker.cpp index 04a1db8..7c2e18d 100644 --- a/bbb_life_tracker/bbb_life_tracker.cpp +++ b/bbb_life_tracker/bbb_life_tracker.cpp @@ -36,14 +36,15 @@ void print_info() cout << "Usage: " << endl << "\t bbb_life_tracker [debug_level]" << endl << endl; cout << "\ttrk_mode:" << endl; cout << "\t\t --avoid [-A] / --follow [-F] -> avoid/follow elements with a temperature compatible to life" << endl; - cout << "\tdebug_ip_address -> the IP address of the destination of the video stream" << endl; - cout << "\tdebug_port -> the port of the destination of the video stream" << endl; + cout << "\tstream_ip_address -> the IP address of the destination of the video stream" << endl; + cout << "\traw_port -> the port of the destination of the raw video stream" << endl; + cout << "\tres_port -> the port of the destination of the video stream with tracking result" << endl; cout << "\tmulticast_interface -> the network interface to multicast the video stream [use \"\" for unicast]" << endl; cout << "\tdebug_level [optional]:" << endl; cout << "\t\t 0 [default] (no debug) - 1 (info debug) - 2 (full debug)" << endl << endl; } -int main( int argc, char *argv[] ) +int main( int argc, char *argv[] ) { gst_init( &argc, &argv ); @@ -63,10 +64,11 @@ int main( int argc, char *argv[] ) std::string track_mode; std::string ip_addr; - uint32_t ip_port; + uint32_t raw_ip_port; + uint32_t res_ip_port; std::string iface; - if( argc != 5 || argc != 6 ) + if( argc != 6 || argc != 7 ) { print_info(); @@ -76,17 +78,33 @@ int main( int argc, char *argv[] ) { track_mode = argv[1]; ip_addr = argv[2]; - string port = argv[3]; + + string raw_port = argv[3]; + + try + { + raw_ip_port = std::stoul(raw_port); + } + catch( const std::invalid_argument& ia ) + { + print_info(); + + cerr << endl << "Invalid argument for 'raw_port': " << ia.what() << endl; + + return EXIT_FAILURE; + } + + string res_port = argv[3]; try { - ip_port = std::stoul(port); + res_ip_port = std::stoul(res_port); } catch( const std::invalid_argument& ia ) { print_info(); - cerr << endl << "Invalid argument for 'debug_port': " << ia.what() << endl; + cerr << endl << "Invalid argument for 'res_port': " << ia.what() << endl; return EXIT_FAILURE; } @@ -116,18 +134,45 @@ int main( int argc, char *argv[] ) } } - // >>>>> Create GStreamer encoder - videoEncoder* gstEncoder = NULL; + // >>>>> Create GStreamer encoder for raw stream + videoEncoder* gstEncoderRaw = NULL; + + gstEncoderRaw = videoEncoder::Create( 160, 120, + iface, + ip_addr, + raw_ip_port, + 1024, + "gst_encoder"); + + if( !gstEncoderRaw) + { + cerr << "Cannot create Encoder for Raw Video Stream" << endl; + + return EXIT_FAILURE; + } + + gstEncoderRaw->Open(); + // <<<<< Create GStreamer encoder for raw stream - gstEncoder = videoEncoder::Create( 160, 120, + // >>>>> Create GStreamer encoder for res stream + videoEncoder* gstEncoderRes = NULL; + + gstEncoderRes = videoEncoder::Create( 160, 120, iface, ip_addr, - ip_port, + res_ip_port, 1024, "gst_encoder"); - gstEncoder->Open(); - // <<<<< Create GStreamer encoder + if( !gstEncoderRes) + { + cerr << "Cannot create Encoder for Result Video Stream" << endl; + + return EXIT_FAILURE; + } + + gstEncoderRes->Open(); + // <<<<< Create GStreamer encoder for res stream */ Lepton3 lepton3( "/dev/spidev1.0", 1, deb_lvl ); @@ -193,8 +238,6 @@ int main( int argc, char *argv[] ) } else { - lepton3.stop(); - print_info(); cerr << endl << "Invalid argument for 'trk_mode'" << endl; @@ -229,42 +272,48 @@ int main( int argc, char *argv[] ) double freq = (1000.*1000.)/period_usec; cv::Mat frame16( h, w, CV_16UC1 ); - cv::Mat frameRGB( h, w, CV_8UC3 ); + + cv::Mat frameRes; memcpy( frame16.data, data16, w*h*sizeof(uint16_t) ); // >>>>> Tracking - if( !tracker.setNewFrame( frame16 ) ) + if( tracker.setNewFrame( frame16, min, max ) != FlirTracker::TRK_RES_ERROR ) { if( deb_lvl>=Lepton3::DBG_INFO ) { cout << "*** Error performing tracking step on frame #" << frameIdx << endl; } + + frameRes = tracker.getResFrameRGB(); } // <<<<< Tracking - // >>>>> Rescaling/Normalization to 8bit to visualize data - double diff = static_cast(max - min); // Image range - double scale = 255./diff; // Scale factor - - frame16 -= min; // Bias - frame16 *= scale; // Rescale data - - cv::Mat frame8; - frame16.convertTo( frame8, CV_8UC1 ); - // <<<<< Rescaling/Normalization to 8bit to visualize data + if(gstEncoderRaw) + { + cv::Mat frameRGB; - cv::cvtColor( frame8,frameRGB, CV_GRAY2RGB ); + frameRGB = FlirTracker::normalizeFrame( frame16, min, max ); - if(gstEncoder) - { cv::Mat frameYUV( h+h/2, w, CV_8UC1 ); cv::cvtColor( frameRGB, frameYUV, cv::COLOR_RGB2YUV_I420 ); - gstEncoder->PushFrame( (uint8_t*)frameYUV.data ); + gstEncoderRaw->PushFrame( (uint8_t*)frameYUV.data ); if( deb_lvl>=Lepton3::DBG_FULL ) { - cout << "Frame pushed" << endl; + cout << "Frame Raw pushed" << endl; + } + } + + if(gstEncoderRes && !frameRes.empty() ) + { + cv::Mat frameYUV( h+h/2, w, CV_8UC1 ); + cv::cvtColor( frameRes, frameYUV, cv::COLOR_RGB2YUV_I420 ); + gstEncoderRes->PushFrame( (uint8_t*)frameYUV.data ); + + if( deb_lvl>=Lepton3::DBG_FULL ) + { + cout << "Frame Res pushed" << endl; } } @@ -281,9 +330,14 @@ int main( int argc, char *argv[] ) lepton3.stop(); - if(gstEncoder) + if(gstEncoderRaw) + { + delete gstEncoderRaw; + } + + if(gstEncoderRes) { - delete gstEncoder; + delete gstEncoderRes; } diff --git a/grabber_lib/src/Palettes.cpp b/bbb_life_tracker/flir_tracker/src/Palettes.cpp similarity index 79% rename from grabber_lib/src/Palettes.cpp rename to bbb_life_tracker/flir_tracker/src/Palettes.cpp index 1b9db6d..86fc2d2 100644 --- a/grabber_lib/src/Palettes.cpp +++ b/bbb_life_tracker/flir_tracker/src/Palettes.cpp @@ -1,14 +1,14 @@ #include -const int colormap_rainbow[] = {1, 3, 74, 0, 3, 74, 0, 3, 75, 0, 3, 75, 0, 3, 76, 0, 3, 76, 0, 3, 77, 0, 3, 79, 0, 3, 82, 0, 5, 85, 0, 7, 88, 0, 10, 91, 0, 14, 94, 0, 19, 98, 0, 22, 100, 0, 25, 103, 0, 28, 106, 0, 32, 109, 0, 35, 112, 0, 38, 116, 0, 40, 119, 0, 42, 123, 0, 45, 128, 0, 49, 133, 0, 50, 134, 0, 51, 136, 0, 52, 137, 0, 53, 139, 0, 54, 142, 0, 55, 144, 0, 56, 145, 0, 58, 149, 0, 61, 154, 0, 63, 156, 0, 65, 159, 0, 66, 161, 0, 68, 164, 0, 69, 167, 0, 71, 170, 0, 73, 174, 0, 75, 179, 0, 76, 181, 0, 78, 184, 0, 79, 187, 0, 80, 188, 0, 81, 190, 0, 84, 194, 0, 87, 198, 0, 88, 200, 0, 90, 203, 0, 92, 205, 0, 94, 207, 0, 94, 208, 0, 95, 209, 0, 96, 210, 0, 97, 211, 0, 99, 214, 0, 102, 217, 0, 103, 218, 0, 104, 219, 0, 105, 220, 0, 107, 221, 0, 109, 223, 0, 111, 223, 0, 113, 223, 0, 115, 222, 0, 117, 221, 0, 118, 220, 1, 120, 219, 1, 122, 217, 2, 124, 216, 2, 126, 214, 3, 129, 212, 3, 131, 207, 4, 132, 205, 4, 133, 202, 4, 134, 197, 5, 136, 192, 6, 138, 185, 7, 141, 178, 8, 142, 172, 10, 144, 166, 10, 144, 162, 11, 145, 158, 12, 146, 153, 13, 147, 149, 15, 149, 140, 17, 151, 132, 22, 153, 120, 25, 154, 115, 28, 156, 109, 34, 158, 101, 40, 160, 94, 45, 162, 86, 51, 164, 79, 59, 167, 69, 67, 171, 60, 72, 173, 54, 78, 175, 48, 83, 177, 43, 89, 179, 39, 93, 181, 35, 98, 183, 31, 105, 185, 26, 109, 187, 23, 113, 188, 21, 118, 189, 19, 123, 191, 17, 128, 193, 14, 134, 195, 12, 138, 196, 10, 142, 197, 8, 146, 198, 6, 151, 200, 5, 155, 201, 4, 160, 203, 3, 164, 204, 2, 169, 205, 2, 173, 206, 1, 175, 207, 1, 178, 207, 1, 184, 208, 0, 190, 210, 0, 193, 211, 0, 196, 212, 0, 199, 212, 0, 202, 213, 1, 207, 214, 2, 212, 215, 3, 215, 214, 3, 218, 214, 3, 220, 213, 3, 222, 213, 4, 224, 212, 4, 225, 212, 5, 226, 212, 5, 229, 211, 5, 232, 211, 6, 232, 211, 6, 233, 211, 6, 234, 210, 6, 235, 210, 7, 236, 209, 7, 237, 208, 8, 239, 206, 8, 241, 204, 9, 242, 203, 9, 244, 202, 10, 244, 201, 10, 245, 200, 10, 245, 199, 11, 246, 198, 11, 247, 197, 12, 248, 194, 13, 249, 191, 14, 250, 189, 14, 251, 187, 15, 251, 185, 16, 252, 183, 17, 252, 178, 18, 253, 174, 19, 253, 171, 19, 254, 168, 20, 254, 165, 21, 254, 164, 21, 255, 163, 22, 255, 161, 22, 255, 159, 23, 255, 157, 23, 255, 155, 24, 255, 149, 25, 255, 143, 27, 255, 139, 28, 255, 135, 30, 255, 131, 31, 255, 127, 32, 255, 118, 34, 255, 110, 36, 255, 104, 37, 255, 101, 38, 255, 99, 39, 255, 93, 40, 255, 88, 42, 254, 82, 43, 254, 77, 45, 254, 69, 47, 254, 62, 49, 253, 57, 50, 253, 53, 52, 252, 49, 53, 252, 45, 55, 251, 39, 57, 251, 33, 59, 251, 32, 60, 251, 31, 60, 251, 30, 61, 251, 29, 61, 251, 28, 62, 250, 27, 63, 250, 27, 65, 249, 26, 66, 249, 26, 68, 248, 25, 70, 248, 24, 73, 247, 24, 75, 247, 25, 77, 247, 25, 79, 247, 26, 81, 247, 32, 83, 247, 35, 85, 247, 38, 86, 247, 42, 88, 247, 46, 90, 247, 50, 92, 248, 55, 94, 248, 59, 96, 248, 64, 98, 248, 72, 101, 249, 81, 104, 249, 87, 106, 250, 93, 108, 250, 95, 109, 250, 98, 110, 250, 100, 111, 251, 101, 112, 251, 102, 113, 251, 109, 117, 252, 116, 121, 252, 121, 123, 253, 126, 126, 253, 130, 128, 254, 135, 131, 254, 139, 133, 254, 144, 136, 254, 151, 140, 255, 158, 144, 255, 163, 146, 255, 168, 149, 255, 173, 152, 255, 176, 153, 255, 178, 155, 255, 184, 160, 255, 191, 165, 255, 195, 168, 255, 199, 172, 255, 203, 175, 255, 207, 179, 255, 211, 182, 255, 216, 185, 255, 218, 190, 255, 220, 196, 255, 222, 200, 255, 225, 202, 255, 227, 204, 255, 230, 206, 255, 233, 208}; +const uint8_t colormap_rainbow[] = {1, 3, 74, 0, 3, 74, 0, 3, 75, 0, 3, 75, 0, 3, 76, 0, 3, 76, 0, 3, 77, 0, 3, 79, 0, 3, 82, 0, 5, 85, 0, 7, 88, 0, 10, 91, 0, 14, 94, 0, 19, 98, 0, 22, 100, 0, 25, 103, 0, 28, 106, 0, 32, 109, 0, 35, 112, 0, 38, 116, 0, 40, 119, 0, 42, 123, 0, 45, 128, 0, 49, 133, 0, 50, 134, 0, 51, 136, 0, 52, 137, 0, 53, 139, 0, 54, 142, 0, 55, 144, 0, 56, 145, 0, 58, 149, 0, 61, 154, 0, 63, 156, 0, 65, 159, 0, 66, 161, 0, 68, 164, 0, 69, 167, 0, 71, 170, 0, 73, 174, 0, 75, 179, 0, 76, 181, 0, 78, 184, 0, 79, 187, 0, 80, 188, 0, 81, 190, 0, 84, 194, 0, 87, 198, 0, 88, 200, 0, 90, 203, 0, 92, 205, 0, 94, 207, 0, 94, 208, 0, 95, 209, 0, 96, 210, 0, 97, 211, 0, 99, 214, 0, 102, 217, 0, 103, 218, 0, 104, 219, 0, 105, 220, 0, 107, 221, 0, 109, 223, 0, 111, 223, 0, 113, 223, 0, 115, 222, 0, 117, 221, 0, 118, 220, 1, 120, 219, 1, 122, 217, 2, 124, 216, 2, 126, 214, 3, 129, 212, 3, 131, 207, 4, 132, 205, 4, 133, 202, 4, 134, 197, 5, 136, 192, 6, 138, 185, 7, 141, 178, 8, 142, 172, 10, 144, 166, 10, 144, 162, 11, 145, 158, 12, 146, 153, 13, 147, 149, 15, 149, 140, 17, 151, 132, 22, 153, 120, 25, 154, 115, 28, 156, 109, 34, 158, 101, 40, 160, 94, 45, 162, 86, 51, 164, 79, 59, 167, 69, 67, 171, 60, 72, 173, 54, 78, 175, 48, 83, 177, 43, 89, 179, 39, 93, 181, 35, 98, 183, 31, 105, 185, 26, 109, 187, 23, 113, 188, 21, 118, 189, 19, 123, 191, 17, 128, 193, 14, 134, 195, 12, 138, 196, 10, 142, 197, 8, 146, 198, 6, 151, 200, 5, 155, 201, 4, 160, 203, 3, 164, 204, 2, 169, 205, 2, 173, 206, 1, 175, 207, 1, 178, 207, 1, 184, 208, 0, 190, 210, 0, 193, 211, 0, 196, 212, 0, 199, 212, 0, 202, 213, 1, 207, 214, 2, 212, 215, 3, 215, 214, 3, 218, 214, 3, 220, 213, 3, 222, 213, 4, 224, 212, 4, 225, 212, 5, 226, 212, 5, 229, 211, 5, 232, 211, 6, 232, 211, 6, 233, 211, 6, 234, 210, 6, 235, 210, 7, 236, 209, 7, 237, 208, 8, 239, 206, 8, 241, 204, 9, 242, 203, 9, 244, 202, 10, 244, 201, 10, 245, 200, 10, 245, 199, 11, 246, 198, 11, 247, 197, 12, 248, 194, 13, 249, 191, 14, 250, 189, 14, 251, 187, 15, 251, 185, 16, 252, 183, 17, 252, 178, 18, 253, 174, 19, 253, 171, 19, 254, 168, 20, 254, 165, 21, 254, 164, 21, 255, 163, 22, 255, 161, 22, 255, 159, 23, 255, 157, 23, 255, 155, 24, 255, 149, 25, 255, 143, 27, 255, 139, 28, 255, 135, 30, 255, 131, 31, 255, 127, 32, 255, 118, 34, 255, 110, 36, 255, 104, 37, 255, 101, 38, 255, 99, 39, 255, 93, 40, 255, 88, 42, 254, 82, 43, 254, 77, 45, 254, 69, 47, 254, 62, 49, 253, 57, 50, 253, 53, 52, 252, 49, 53, 252, 45, 55, 251, 39, 57, 251, 33, 59, 251, 32, 60, 251, 31, 60, 251, 30, 61, 251, 29, 61, 251, 28, 62, 250, 27, 63, 250, 27, 65, 249, 26, 66, 249, 26, 68, 248, 25, 70, 248, 24, 73, 247, 24, 75, 247, 25, 77, 247, 25, 79, 247, 26, 81, 247, 32, 83, 247, 35, 85, 247, 38, 86, 247, 42, 88, 247, 46, 90, 247, 50, 92, 248, 55, 94, 248, 59, 96, 248, 64, 98, 248, 72, 101, 249, 81, 104, 249, 87, 106, 250, 93, 108, 250, 95, 109, 250, 98, 110, 250, 100, 111, 251, 101, 112, 251, 102, 113, 251, 109, 117, 252, 116, 121, 252, 121, 123, 253, 126, 126, 253, 130, 128, 254, 135, 131, 254, 139, 133, 254, 144, 136, 254, 151, 140, 255, 158, 144, 255, 163, 146, 255, 168, 149, 255, 173, 152, 255, 176, 153, 255, 178, 155, 255, 184, 160, 255, 191, 165, 255, 195, 168, 255, 199, 172, 255, 203, 175, 255, 207, 179, 255, 211, 182, 255, 216, 185, 255, 218, 190, 255, 220, 196, 255, 222, 200, 255, 225, 202, 255, 227, 204, 255, 230, 206, 255, 233, 208}; -const int colormap_grayscale[] = {0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 41, 42, 42, 42, 43, 43, 43, 44, 44, 44, 45, 45, 45, 46, 46, 46, 47, 47, 47, 48, 48, 48, 49, 49, 49, 50, 50, 50, 51, 51, 51, 52, 52, 52, 53, 53, 53, 54, 54, 54, 55, 55, 55, 56, 56, 56, 57, 57, 57, 58, 58, 58, 59, 59, 59, 60, 60, 60, 61, 61, 61, 62, 62, 62, 63, 63, 63, 64, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67, 67, 68, 68, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71, 72, 72, 72, 73, 73, 73, 74, 74, 74, 75, 75, 75, 76, 76, 76, 77, 77, 77, 78, 78, 78, 79, 79, 79, 80, 80, 80, 81, 81, 81, 82, 82, 82, 83, 83, 83, 84, 84, 84, 85, 85, 85, 86, 86, 86, 87, 87, 87, 88, 88, 88, 89, 89, 89, 90, 90, 90, 91, 91, 91, 92, 92, 92, 93, 93, 93, 94, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 98, 98, 98, 99, 99, 99, 100, 100, 100, 101, 101, 101, 102, 102, 102, 103, 103, 103, 104, 104, 104, 105, 105, 105, 106, 106, 106, 107, 107, 107, 108, 108, 108, 109, 109, 109, 110, 110, 110, 111, 111, 111, 112, 112, 112, 113, 113, 113, 114, 114, 114, 115, 115, 115, 116, 116, 116, 117, 117, 117, 118, 118, 118, 119, 119, 119, 120, 120, 120, 121, 121, 121, 122, 122, 122, 123, 123, 123, 124, 124, 124, 125, 125, 125, 126, 126, 126, 127, 127, 127, 128, 128, 128, 129, 129, 129, 130, 130, 130, 131, 131, 131, 132, 132, 132, 133, 133, 133, 134, 134, 134, 135, 135, 135, 136, 136, 136, 137, 137, 137, 138, 138, 138, 139, 139, 139, 140, 140, 140, 141, 141, 141, 142, 142, 142, 143, 143, 143, 144, 144, 144, 145, 145, 145, 146, 146, 146, 147, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151, 152, 152, 152, 153, 153, 153, 154, 154, 154, 155, 155, 155, 156, 156, 156, 157, 157, 157, 158, 158, 158, 159, 159, 159, 160, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164, 165, 165, 165, 166, 166, 166, 167, 167, 167, 168, 168, 168, 169, 169, 169, 170, 170, 170, 171, 171, 171, 172, 172, 172, 173, 173, 173, 174, 174, 174, 175, 175, 175, 176, 176, 176, 177, 177, 177, 178, 178, 178, 179, 179, 179, 180, 180, 180, 181, 181, 181, 182, 182, 182, 183, 183, 183, 184, 184, 184, 185, 185, 185, 186, 186, 186, 187, 187, 187, 188, 188, 188, 189, 189, 189, 190, 190, 190, 191, 191, 191, 192, 192, 192, 193, 193, 193, 194, 194, 194, 195, 195, 195, 196, 196, 196, 197, 197, 197, 198, 198, 198, 199, 199, 199, 200, 200, 200, 201, 201, 201, 202, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 205, 206, 206, 206, 207, 207, 207, 208, 208, 208, 209, 209, 209, 210, 210, 210, 211, 211, 211, 212, 212, 212, 213, 213, 213, 214, 214, 214, 215, 215, 215, 216, 216, 216, 217, 217, 217, 218, 218, 218, 219, 219, 219, 220, 220, 220, 221, 221, 221, 222, 222, 222, 223, 223, 223, 224, 224, 224, 225, 225, 225, 226, 226, 226, 227, 227, 227, 228, 228, 228, 229, 229, 229, 230, 230, 230, 231, 231, 231, 232, 232, 232, 233, 233, 233, 234, 234, 234, 235, 235, 235, 236, 236, 236, 237, 237, 237, 238, 238, 238, 239, 239, 239, 240, 240, 240, 241, 241, 241, 242, 242, 242, 243, 243, 243, 244, 244, 244, 245, 245, 245, 246, 246, 246, 247, 247, 247, 248, 248, 248, 249, 249, 249, 250, 250, 250, 251, 251, 251, 252, 252, 252, 253, 253, 253, 254, 254, 254, 255, 255, 255}; +const uint8_t colormap_grayscale[] = {0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 41, 42, 42, 42, 43, 43, 43, 44, 44, 44, 45, 45, 45, 46, 46, 46, 47, 47, 47, 48, 48, 48, 49, 49, 49, 50, 50, 50, 51, 51, 51, 52, 52, 52, 53, 53, 53, 54, 54, 54, 55, 55, 55, 56, 56, 56, 57, 57, 57, 58, 58, 58, 59, 59, 59, 60, 60, 60, 61, 61, 61, 62, 62, 62, 63, 63, 63, 64, 64, 64, 65, 65, 65, 66, 66, 66, 67, 67, 67, 68, 68, 68, 69, 69, 69, 70, 70, 70, 71, 71, 71, 72, 72, 72, 73, 73, 73, 74, 74, 74, 75, 75, 75, 76, 76, 76, 77, 77, 77, 78, 78, 78, 79, 79, 79, 80, 80, 80, 81, 81, 81, 82, 82, 82, 83, 83, 83, 84, 84, 84, 85, 85, 85, 86, 86, 86, 87, 87, 87, 88, 88, 88, 89, 89, 89, 90, 90, 90, 91, 91, 91, 92, 92, 92, 93, 93, 93, 94, 94, 94, 95, 95, 95, 96, 96, 96, 97, 97, 97, 98, 98, 98, 99, 99, 99, 100, 100, 100, 101, 101, 101, 102, 102, 102, 103, 103, 103, 104, 104, 104, 105, 105, 105, 106, 106, 106, 107, 107, 107, 108, 108, 108, 109, 109, 109, 110, 110, 110, 111, 111, 111, 112, 112, 112, 113, 113, 113, 114, 114, 114, 115, 115, 115, 116, 116, 116, 117, 117, 117, 118, 118, 118, 119, 119, 119, 120, 120, 120, 121, 121, 121, 122, 122, 122, 123, 123, 123, 124, 124, 124, 125, 125, 125, 126, 126, 126, 127, 127, 127, 128, 128, 128, 129, 129, 129, 130, 130, 130, 131, 131, 131, 132, 132, 132, 133, 133, 133, 134, 134, 134, 135, 135, 135, 136, 136, 136, 137, 137, 137, 138, 138, 138, 139, 139, 139, 140, 140, 140, 141, 141, 141, 142, 142, 142, 143, 143, 143, 144, 144, 144, 145, 145, 145, 146, 146, 146, 147, 147, 147, 148, 148, 148, 149, 149, 149, 150, 150, 150, 151, 151, 151, 152, 152, 152, 153, 153, 153, 154, 154, 154, 155, 155, 155, 156, 156, 156, 157, 157, 157, 158, 158, 158, 159, 159, 159, 160, 160, 160, 161, 161, 161, 162, 162, 162, 163, 163, 163, 164, 164, 164, 165, 165, 165, 166, 166, 166, 167, 167, 167, 168, 168, 168, 169, 169, 169, 170, 170, 170, 171, 171, 171, 172, 172, 172, 173, 173, 173, 174, 174, 174, 175, 175, 175, 176, 176, 176, 177, 177, 177, 178, 178, 178, 179, 179, 179, 180, 180, 180, 181, 181, 181, 182, 182, 182, 183, 183, 183, 184, 184, 184, 185, 185, 185, 186, 186, 186, 187, 187, 187, 188, 188, 188, 189, 189, 189, 190, 190, 190, 191, 191, 191, 192, 192, 192, 193, 193, 193, 194, 194, 194, 195, 195, 195, 196, 196, 196, 197, 197, 197, 198, 198, 198, 199, 199, 199, 200, 200, 200, 201, 201, 201, 202, 202, 202, 203, 203, 203, 204, 204, 204, 205, 205, 205, 206, 206, 206, 207, 207, 207, 208, 208, 208, 209, 209, 209, 210, 210, 210, 211, 211, 211, 212, 212, 212, 213, 213, 213, 214, 214, 214, 215, 215, 215, 216, 216, 216, 217, 217, 217, 218, 218, 218, 219, 219, 219, 220, 220, 220, 221, 221, 221, 222, 222, 222, 223, 223, 223, 224, 224, 224, 225, 225, 225, 226, 226, 226, 227, 227, 227, 228, 228, 228, 229, 229, 229, 230, 230, 230, 231, 231, 231, 232, 232, 232, 233, 233, 233, 234, 234, 234, 235, 235, 235, 236, 236, 236, 237, 237, 237, 238, 238, 238, 239, 239, 239, 240, 240, 240, 241, 241, 241, 242, 242, 242, 243, 243, 243, 244, 244, 244, 245, 245, 245, 246, 246, 246, 247, 247, 247, 248, 248, 248, 249, 249, 249, 250, 250, 250, 251, 251, 251, 252, 252, 252, 253, 253, 253, 254, 254, 254, 255, 255, 255}; -const int colormap_ironblack[] = {255, 255, 255, 253, 253, 253, 251, 251, 251, 249, 249, 249, 247, 247, 247, 245, 245, 245, 243, 243, 243, 241, 241, 241, 239, 239, 239, 237, 237, 237, 235, 235, 235, 233, 233, 233, 231, 231, 231, 229, 229, 229, 227, 227, 227, 225, 225, 225, 223, 223, 223, 221, 221, 221, 219, 219, 219, 217, 217, 217, 215, 215, 215, 213, 213, 213, 211, 211, 211, 209, 209, 209, 207, 207, 207, 205, 205, 205, 203, 203, 203, 201, 201, 201, 199, 199, 199, 197, 197, 197, 195, 195, 195, 193, 193, 193, 191, 191, 191, 189, 189, 189, 187, 187, 187, 185, 185, 185, 183, 183, 183, 181, 181, 181, 179, 179, 179, 177, 177, 177, 175, 175, 175, 173, 173, 173, 171, 171, 171, 169, 169, 169, 167, 167, 167, 165, 165, 165, 163, 163, 163, 161, 161, 161, 159, 159, 159, 157, 157, 157, 155, 155, 155, 153, 153, 153, 151, 151, 151, 149, 149, 149, 147, 147, 147, 145, 145, 145, 143, 143, 143, 141, 141, 141, 139, 139, 139, 137, 137, 137, 135, 135, 135, 133, 133, 133, 131, 131, 131, 129, 129, 129, 126, 126, 126, 124, 124, 124, 122, 122, 122, 120, 120, 120, 118, 118, 118, 116, 116, 116, 114, 114, 114, 112, 112, 112, 110, 110, 110, 108, 108, 108, 106, 106, 106, 104, 104, 104, 102, 102, 102, 100, 100, 100, 98, 98, 98, 96, 96, 96, 94, 94, 94, 92, 92, 92, 90, 90, 90, 88, 88, 88, 86, 86, 86, 84, 84, 84, 82, 82, 82, 80, 80, 80, 78, 78, 78, 76, 76, 76, 74, 74, 74, 72, 72, 72, 70, 70, 70, 68, 68, 68, 66, 66, 66, 64, 64, 64, 62, 62, 62, 60, 60, 60, 58, 58, 58, 56, 56, 56, 54, 54, 54, 52, 52, 52, 50, 50, 50, 48, 48, 48, 46, 46, 46, 44, 44, 44, 42, 42, 42, 40, 40, 40, 38, 38, 38, 36, 36, 36, 34, 34, 34, 32, 32, 32, 30, 30, 30, 28, 28, 28, 26, 26, 26, 24, 24, 24, 22, 22, 22, 20, 20, 20, 18, 18, 18, 16, 16, 16, 14, 14, 14, 12, 12, 12, 10, 10, 10, 8, 8, 8, 6, 6, 6, 4, 4, 4, 2, 2, 2, 0, 0, 0, 0, 0, 9, 2, 0, 16, 4, 0, 24, 6, 0, 31, 8, 0, 38, 10, 0, 45, 12, 0, 53, 14, 0, 60, 17, 0, 67, 19, 0, 74, 21, 0, 82, 23, 0, 89, 25, 0, 96, 27, 0, 103, 29, 0, 111, 31, 0, 118, 36, 0, 120, 41, 0, 121, 46, 0, 122, 51, 0, 123, 56, 0, 124, 61, 0, 125, 66, 0, 126, 71, 0, 127, 76, 1, 128, 81, 1, 129, 86, 1, 130, 91, 1, 131, 96, 1, 132, 101, 1, 133, 106, 1, 134, 111, 1, 135, 116, 1, 136, 121, 1, 136, 125, 2, 137, 130, 2, 137, 135, 3, 137, 139, 3, 138, 144, 3, 138, 149, 4, 138, 153, 4, 139, 158, 5, 139, 163, 5, 139, 167, 5, 140, 172, 6, 140, 177, 6, 140, 181, 7, 141, 186, 7, 141, 189, 10, 137, 191, 13, 132, 194, 16, 127, 196, 19, 121, 198, 22, 116, 200, 25, 111, 203, 28, 106, 205, 31, 101, 207, 34, 95, 209, 37, 90, 212, 40, 85, 214, 43, 80, 216, 46, 75, 218, 49, 69, 221, 52, 64, 223, 55, 59, 224, 57, 49, 225, 60, 47, 226, 64, 44, 227, 67, 42, 228, 71, 39, 229, 74, 37, 230, 78, 34, 231, 81, 32, 231, 85, 29, 232, 88, 27, 233, 92, 24, 234, 95, 22, 235, 99, 19, 236, 102, 17, 237, 106, 14, 238, 109, 12, 239, 112, 12, 240, 116, 12, 240, 119, 12, 241, 123, 12, 241, 127, 12, 242, 130, 12, 242, 134, 12, 243, 138, 12, 243, 141, 13, 244, 145, 13, 244, 149, 13, 245, 152, 13, 245, 156, 13, 246, 160, 13, 246, 163, 13, 247, 167, 13, 247, 171, 13, 248, 175, 14, 248, 178, 15, 249, 182, 16, 249, 185, 18, 250, 189, 19, 250, 192, 20, 251, 196, 21, 251, 199, 22, 252, 203, 23, 252, 206, 24, 253, 210, 25, 253, 213, 27, 254, 217, 28, 254, 220, 29, 255, 224, 30, 255, 227, 39, 255, 229, 53, 255, 231, 67, 255, 233, 81, 255, 234, 95, 255, 236, 109, 255, 238, 123, 255, 240, 137, 255, 242, 151, 255, 244, 165, 255, 246, 179, 255, 248, 193, 255, 249, 207, 255, 251, 221, 255, 253, 235, 255, 255, 24}; +const uint8_t colormap_ironblack[] = {255, 255, 255, 253, 253, 253, 251, 251, 251, 249, 249, 249, 247, 247, 247, 245, 245, 245, 243, 243, 243, 241, 241, 241, 239, 239, 239, 237, 237, 237, 235, 235, 235, 233, 233, 233, 231, 231, 231, 229, 229, 229, 227, 227, 227, 225, 225, 225, 223, 223, 223, 221, 221, 221, 219, 219, 219, 217, 217, 217, 215, 215, 215, 213, 213, 213, 211, 211, 211, 209, 209, 209, 207, 207, 207, 205, 205, 205, 203, 203, 203, 201, 201, 201, 199, 199, 199, 197, 197, 197, 195, 195, 195, 193, 193, 193, 191, 191, 191, 189, 189, 189, 187, 187, 187, 185, 185, 185, 183, 183, 183, 181, 181, 181, 179, 179, 179, 177, 177, 177, 175, 175, 175, 173, 173, 173, 171, 171, 171, 169, 169, 169, 167, 167, 167, 165, 165, 165, 163, 163, 163, 161, 161, 161, 159, 159, 159, 157, 157, 157, 155, 155, 155, 153, 153, 153, 151, 151, 151, 149, 149, 149, 147, 147, 147, 145, 145, 145, 143, 143, 143, 141, 141, 141, 139, 139, 139, 137, 137, 137, 135, 135, 135, 133, 133, 133, 131, 131, 131, 129, 129, 129, 126, 126, 126, 124, 124, 124, 122, 122, 122, 120, 120, 120, 118, 118, 118, 116, 116, 116, 114, 114, 114, 112, 112, 112, 110, 110, 110, 108, 108, 108, 106, 106, 106, 104, 104, 104, 102, 102, 102, 100, 100, 100, 98, 98, 98, 96, 96, 96, 94, 94, 94, 92, 92, 92, 90, 90, 90, 88, 88, 88, 86, 86, 86, 84, 84, 84, 82, 82, 82, 80, 80, 80, 78, 78, 78, 76, 76, 76, 74, 74, 74, 72, 72, 72, 70, 70, 70, 68, 68, 68, 66, 66, 66, 64, 64, 64, 62, 62, 62, 60, 60, 60, 58, 58, 58, 56, 56, 56, 54, 54, 54, 52, 52, 52, 50, 50, 50, 48, 48, 48, 46, 46, 46, 44, 44, 44, 42, 42, 42, 40, 40, 40, 38, 38, 38, 36, 36, 36, 34, 34, 34, 32, 32, 32, 30, 30, 30, 28, 28, 28, 26, 26, 26, 24, 24, 24, 22, 22, 22, 20, 20, 20, 18, 18, 18, 16, 16, 16, 14, 14, 14, 12, 12, 12, 10, 10, 10, 8, 8, 8, 6, 6, 6, 4, 4, 4, 2, 2, 2, 0, 0, 0, 0, 0, 9, 2, 0, 16, 4, 0, 24, 6, 0, 31, 8, 0, 38, 10, 0, 45, 12, 0, 53, 14, 0, 60, 17, 0, 67, 19, 0, 74, 21, 0, 82, 23, 0, 89, 25, 0, 96, 27, 0, 103, 29, 0, 111, 31, 0, 118, 36, 0, 120, 41, 0, 121, 46, 0, 122, 51, 0, 123, 56, 0, 124, 61, 0, 125, 66, 0, 126, 71, 0, 127, 76, 1, 128, 81, 1, 129, 86, 1, 130, 91, 1, 131, 96, 1, 132, 101, 1, 133, 106, 1, 134, 111, 1, 135, 116, 1, 136, 121, 1, 136, 125, 2, 137, 130, 2, 137, 135, 3, 137, 139, 3, 138, 144, 3, 138, 149, 4, 138, 153, 4, 139, 158, 5, 139, 163, 5, 139, 167, 5, 140, 172, 6, 140, 177, 6, 140, 181, 7, 141, 186, 7, 141, 189, 10, 137, 191, 13, 132, 194, 16, 127, 196, 19, 121, 198, 22, 116, 200, 25, 111, 203, 28, 106, 205, 31, 101, 207, 34, 95, 209, 37, 90, 212, 40, 85, 214, 43, 80, 216, 46, 75, 218, 49, 69, 221, 52, 64, 223, 55, 59, 224, 57, 49, 225, 60, 47, 226, 64, 44, 227, 67, 42, 228, 71, 39, 229, 74, 37, 230, 78, 34, 231, 81, 32, 231, 85, 29, 232, 88, 27, 233, 92, 24, 234, 95, 22, 235, 99, 19, 236, 102, 17, 237, 106, 14, 238, 109, 12, 239, 112, 12, 240, 116, 12, 240, 119, 12, 241, 123, 12, 241, 127, 12, 242, 130, 12, 242, 134, 12, 243, 138, 12, 243, 141, 13, 244, 145, 13, 244, 149, 13, 245, 152, 13, 245, 156, 13, 246, 160, 13, 246, 163, 13, 247, 167, 13, 247, 171, 13, 248, 175, 14, 248, 178, 15, 249, 182, 16, 249, 185, 18, 250, 189, 19, 250, 192, 20, 251, 196, 21, 251, 199, 22, 252, 203, 23, 252, 206, 24, 253, 210, 25, 253, 213, 27, 254, 217, 28, 254, 220, 29, 255, 224, 30, 255, 227, 39, 255, 229, 53, 255, 231, 67, 255, 233, 81, 255, 234, 95, 255, 236, 109, 255, 238, 123, 255, 240, 137, 255, 242, 151, 255, 244, 165, 255, 246, 179, 255, 248, 193, 255, 249, 207, 255, 251, 221, 255, 253, 235, 255, 255, 24}; -const int colormap_arctic[] = {15, 16, 146, 15, 16, 146, 15, 15, 153, 15, 15, 153, 15, 15, 159, 15, 15, 159, 16, 15, 167, 16, 15, +const uint8_t colormap_arctic[] = {15, 16, 146, 15, 16, 146, 15, 15, 153, 15, 15, 153, 15, 15, 159, 15, 15, 159, 16, 15, 167, 16, 15, 167, 15, 15, 175, 15, 15, 175, 16, 15, 182, 16, 15, 182, 16, 16, 190, 16, 16, 190, 14, 15, 197, 14, 15, 197, 15, 15, 205, 15, 15, 205, 15, 15, 211, 15, 15, 211, 16, 15, 219, 16, 15, 219, 16, 15, 227, 16, 15, 227, 16, 18, 239, 16, 18, 239, 16, 25, 240, 16, 25, 240, 15, 34, 239, 15, 34, 239, 15, 44, @@ -44,7 +44,7 @@ const int colormap_arctic[] = {15, 16, 146, 15, 16, 146, 15, 15, 153, 15, 15, 15 227, 182, 236, 227, 182, 235, 229, 191, 235, 229, 191, 235, 230, 194, 235, 230, 194}; -const int colormap_blackHot[] = {235, 235, 235, 234, 234, 234, 233, 233, 233, 232, 232, 232, 231, 231, 231, 230, 230, 230, 229, 229, +const uint8_t colormap_blackHot[] = {235, 235, 235, 234, 234, 234, 233, 233, 233, 232, 232, 232, 231, 231, 231, 230, 230, 230, 229, 229, 229, 228, 228, 228, 227, 227, 227, 226, 226, 226, 225, 225, 225, 224, 224, 224, 223, 223, 223, 222, 222, 222, 221, 221, 221, 220, 220, 220, 219, 219, 219, 218, 218, 218, 217, 217, 217, 216, 216, 216, 215, 215, 215, 214, 214, 214, 213, 213, 213, 212, 212, 212, 211, 211, 211, 210, 210, 210, 209, 209, @@ -77,7 +77,7 @@ const int colormap_blackHot[] = {235, 235, 235, 234, 234, 234, 233, 233, 233, 23 24, 24, 23, 23, 23, 22, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16}; -const int colormap_blueRed[] = {19, 64, 206, 18, 65, 209, 18, 67, 210, 19, 69, 212, 18, 71, 215, 19, 73, 217, 18, 75, 218, 18, 77, +const uint8_t colormap_blueRed[] = {19, 64, 206, 18, 65, 209, 18, 67, 210, 19, 69, 212, 18, 71, 215, 19, 73, 217, 18, 75, 218, 18, 77, 219, 19, 79, 223, 19, 82, 225, 19, 84, 226, 18, 85, 227, 19, 88, 229, 21, 90, 229, 22, 93, 231, 21, 95, 230, 22, 98, 232, 22, 101, 232, 22, 103, 232, 23, 106, 234, 23, 109, 234, 24, 112, 236, 23, 114, 235, 25, 116, 235, 25, 119, 237, 27, 122, 238, 26, 124, 237, 27, 125, 236, 27, 127, 235, 27, 130, @@ -106,7 +106,7 @@ const int colormap_blueRed[] = {19, 64, 206, 18, 65, 209, 18, 67, 210, 19, 69, 2 33, 15, 139, 31, 15, 134, 30, 15, 131, 30, 14, 128, 28, 14, 126, 28, 15}; -const int colormap_coldest[] = {15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, +const uint8_t colormap_coldest[] = {15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 239, 45, 45, @@ -139,7 +139,7 @@ const int colormap_coldest[] = {15, 15, 239, 15, 15, 239, 15, 15, 239, 15, 15, 2 227, 227, 227, 228, 228, 228, 229, 229, 229, 230, 230, 230, 231, 231, 231, 232, 232, 232, 233, 233, 233, 234, 234, 234, 235, 235, 235}; -const int colormap_contrast[] = {16, 16, 16, 23, 16, 22, 30, 15, 30, 37, 16, 37, 46, 15, 45, 53, 15, 52, 60, 15, 60, 67, 15, 67, 75, +const uint8_t colormap_contrast[] = {16, 16, 16, 23, 16, 22, 30, 15, 30, 37, 16, 37, 46, 15, 45, 53, 15, 52, 60, 15, 60, 67, 15, 67, 75, 15, 75, 82, 15, 81, 89, 15, 90, 98, 14, 96, 105, 14, 105, 112, 14, 111, 120, 15, 121, 127, 15, 127, 135, 15, 135, 143, 14, 142, 150, 14, 150, 158, 14, 157, 165, 14, 165, 172, 14, 172, 179, 14, 180, 186, 14, 187, 195, 14, 195, 202, 14, 201, 209, 14, 210, 217, 14, 216, 209, 15, 214, 202, 14, 211, @@ -172,7 +172,7 @@ const int colormap_contrast[] = {16, 16, 16, 23, 16, 22, 30, 15, 30, 37, 16, 37, 211, 211, 230, 217, 215, 231, 223, 222, 232, 228, 228}; -const int colormap_doubleRainbow[] = {18, 15, 18, 25, 17, 26, 34, 18, 32, 43, 19, 39, 52, 21, 48, 60, 23, 55, 69, 25, 62, 77, 26, +const uint8_t colormap_doubleRainbow[] = {18, 15, 18, 25, 17, 26, 34, 18, 32, 43, 19, 39, 52, 21, 48, 60, 23, 55, 69, 25, 62, 77, 26, 70, 86, 28, 75, 95, 30, 84, 103, 31, 91, 112, 34, 98, 120, 35, 106, 129, 36, 111, 138, 39, 120, 146, 40, 128, 155, 42, 136, 150, 44, 140, 145, 47, 146, 139, 51, 151, 134, 54, 157, 130, 57, 161, 124, 60, 168, 119, 63, 172, 115, 66, 179, 109, 70, 183, 104, 73, 189, 99, 76, 194, @@ -213,7 +213,7 @@ const int colormap_doubleRainbow[] = {18, 15, 18, 25, 17, 26, 34, 18, 32, 43, 19 235}; -const int colormap_grayRed[] = {218, 186, 175, 216, 186, 174, 214, 186, 173, 213, 185, 172, 212, 184, 171, 209, 183, 170, 206, 182, +const uint8_t colormap_grayRed[] = {218, 186, 175, 216, 186, 174, 214, 186, 173, 213, 185, 172, 212, 184, 171, 209, 183, 170, 206, 182, 170, 205, 181, 169, 202, 180, 168, 202, 180, 168, 199, 179, 168, 197, 178, 167, 194, 178, 166, 193, 177, 166, 191, 177, 165, 186, 176, 165, 185, 175, 164, 182, 173, 162, 180, 174, 162, 177, 172, 162, 174, 172, 161, 172, 170, 159, 170, 170, 160, 168, 169, 159, 165, 169, 158, 162, 167, 157, 160, 168, @@ -245,7 +245,7 @@ const int colormap_grayRed[] = {218, 186, 175, 216, 186, 174, 214, 186, 173, 213 25, 27, 232, 24, 26, 232, 24, 26, 231, 23, 25, 231, 23, 25, 230, 22, 24, 232, 21, 24, 231, 20, 23, 230, 19, 22, 229, 18, 21, 230, 18, 21, 229, 17, 20, 229, 17, 20, 228, 16, 19, 227, 15, 18}; -const int colormap_glowBow[] = {16, 16, 16, 19, 17, 18, 22, 16, 16, 25, 17, 18, 28, 17, 19, 31, 17, 20, 34, 17, 19, 36, 18, 20, 39, +const uint8_t colormap_glowBow[] = {16, 16, 16, 19, 17, 18, 22, 16, 16, 25, 17, 18, 28, 17, 19, 31, 17, 20, 34, 17, 19, 36, 18, 20, 39, 18, 19, 43, 19, 21, 45, 18, 21, 48, 20, 21, 52, 19, 22, 54, 20, 23, 58, 20, 23, 63, 21, 23, 68, 21, 25, 70, 21, 26, 73, 22, 27, 75, 22, 26, 79, 22, 27, 81, 22, 28, 84, 23, 27, 87, 22, 28, 91, 24, 30, 96, 23, 30, 102, 24, 33, 104, 25, 32, 108, 25, 33, 110, 25, 34, 117, 25, 34, 120, 27, 34, 122, 27, @@ -277,7 +277,7 @@ const int colormap_glowBow[] = {16, 16, 16, 19, 17, 18, 22, 16, 16, 25, 17, 18, 195, 235, 230, 197, 236, 230, 202, 234, 230, 205, 235, 231, 208, 235, 232, 213, 235, 231, 216, 234, 232, 219, 234, 234, 224, 235, 234, 228, 235, 235, 235}; -const int colormap_hottest[] = {16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, +const uint8_t colormap_hottest[] = {16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 41, 42, 42, 42, 43, 43, 43, 44, 44, 44, 44, 44, 44, 45, 45, 45, 46, 46, 46, 47, 47, 47, 48, @@ -311,7 +311,7 @@ const int colormap_hottest[] = {16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, -const int colormap_lava[] = {16, 16, 16, 17, 19, 22, 19, 21, 30, 20, 24, 37, 22, 27, 43, 22, 31, 50, 24, 32, 57, 25, 37, 65, 26, 39, +const uint8_t colormap_lava[] = {16, 16, 16, 17, 19, 22, 19, 21, 30, 20, 24, 37, 22, 27, 43, 22, 31, 50, 24, 32, 57, 25, 37, 65, 26, 39, 70, 28, 43, 78, 29, 44, 85, 31, 47, 94, 32, 50, 100, 34, 53, 107, 34, 57, 113, 37, 59, 122, 37, 63, 128, 39, 66, 135, 40, 69, 141, 42, 71, 149, 44, 74, 156, 41, 76, 156, 41, 76, 156, 39, 78, 157, 36, 80, 155, 36, 82, 156, 34, 82, 156, 33, 85, 157, 31, 86, 157, 30, 86, 157, 29, 88, 156, 28, 91, 157, 26, 91, @@ -345,7 +345,7 @@ const int colormap_lava[] = {16, 16, 16, 17, 19, 22, 19, 21, 30, 20, 24, 37, 22, 229, 201, 235, 232, 213, 235, 233, 224, 235, 235, 235}; -const int colormap_medical[] = {36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, +const uint8_t colormap_medical[] = {36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 198, 70, 71, 238, 70, 71, 238, 70, 71, 238, 70, 71, 238, 70, 71, 238, 70, 71, 238, 70, 71, 238, 70, 71, 238, 70, 71, @@ -377,7 +377,7 @@ const int colormap_medical[] = {36, 36, 198, 36, 36, 198, 36, 36, 198, 36, 36, 1 236, 196, 37, 236, 196, 37, 236, 196, 37, 236, 196, 37, 236, 196, 37, 236, 196, 37, 236, 196, 37, 236, 196, 37, 236, 196, 37, 236, 196, 37, 236, 196, 37}; -const int colormap_wheel2[] = {17, 14, 17, 16, 23, 17, 17, 32, 17, 16, 40, 16, 16, 49, 16, 15, 58, 16, 15, 65, 16, 14, 74, 16, 15, +const uint8_t colormap_wheel2[] = {17, 14, 17, 16, 23, 17, 17, 32, 17, 16, 40, 16, 16, 49, 16, 15, 58, 16, 15, 65, 16, 14, 74, 16, 15, 82, 16, 15, 91, 15, 14, 100, 15, 15, 108, 15, 14, 117, 14, 15, 125, 16, 14, 134, 15, 14, 143, 15, 15, 151, 15, 14, 160, 14, 15, 168, 14, 14, 177, 14, 14, 186, 13, 13, 192, 14, 13, 201, 14, 14, 209, 13, 14, 219, 14, 13, 228, 14, 14, 236, 13, 22, 227, 22, 28, 219, 29, 37, 212, 37, 46, 204, 46, 52, 196, @@ -415,7 +415,7 @@ const int colormap_wheel2[] = {17, 14, 17, 16, 23, 17, 17, 32, 17, 16, 40, 16, 1 232, 229, 16, 235, 233, 14}; -const int colormap_whiteHot[] = {16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, +const uint8_t colormap_whiteHot[] = {16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 41, 42, 42, 42, 43, 43, 43, 44, 44, 44, 44, 44, 44, 45, 45, 45, 46, 46, 46, 47, 47, 47, 48, diff --git a/bbb_life_tracker/flir_tracker/src/flir_tracker.cpp b/bbb_life_tracker/flir_tracker/src/flir_tracker.cpp index 6dac9e9..c8ba332 100644 --- a/bbb_life_tracker/flir_tracker/src/flir_tracker.cpp +++ b/bbb_life_tracker/flir_tracker/src/flir_tracker.cpp @@ -1,5 +1,13 @@ #include "flir_tracker.h" +#include "Palettes.h" +#include + + +#include +#include + +using namespace std; FlirTracker::FlirTracker(TrackMode trkMode, uint16_t minThresh, uint16_t maxThresh) : mTrkMode(trkMode) @@ -14,14 +22,95 @@ FlirTracker::~FlirTracker() } -bool FlirTracker::setNewFrame( cv::Mat frame16 ) +FlirTracker::TrackRes FlirTracker::setNewFrame( cv::Mat frame16, uint16_t min, uint16_t max ) { + if( frame16.type() != CV_16U ) + { + cerr << "Wrong image type. One channel 16bit image expected" << endl; + return TRK_RES_ERROR; + } + + if( frame16.channels() != 1 ) + { + cerr << "Wrong image channel count. One channel 16bit image expected" << endl; + return TRK_RES_ERROR; + } + + mFrameMin = min; + mFrameMax = max; + mFrame16 = frame16; return doTrackStep(); } -bool FlirTracker::doTrackStep() +FlirTracker::TrackRes FlirTracker::doTrackStep() +{ + cv::inRange( mFrame16, cv::Scalar(mMinThresh), cv::Scalar(mMaxThresh), mResMask ); + + //cv::imshow( "Range mask", mResMask ); + + mFrame16.copyTo(mRes16,mResMask); // Mask + + return TRK_RES_NONE; +} + + +cv::Mat FlirTracker::getResFrameRGB() { + /*if( !mResRGB.empty() ) + return cv::Mat();*/ + + uint16_t max_val = static_cast(pow(2,14)-1); + cv::Mat temp8 = normalizeFrame( mFrame16, 0, max_val ); + + cv::cvtColor( temp8, mResRGB, CV_GRAY2BGR ); + + mResRGB.create(temp8.size(), CV_8UC3 ); + //cv::imshow( "Original_int", mResRGB ); + + for( int r=0; r(r,c); + if( maskVal!=0 ) + { + uint16_t val = temp8.at(r,c); + uint8_t r_ = lut[val+2]; + uint8_t g_ = lut[val+1]; + uint8_t b_ = lut[val+0]; + int idx = 3*(r*160+c); + mResRGB.data[idx+2] = r_; + mResRGB.data[idx+1] = g_; + mResRGB.data[idx+0] = b_; + } + } + cout << endl; + } + + + + return mResRGB; +} + +cv::Mat FlirTracker::normalizeFrame( const cv::Mat& frame16, uint16_t min, uint16_t max ) +{ + cv::Mat tmp16; + frame16.copyTo( tmp16); + + // >>>>> Rescaling/Normalization to 8bit + double diff = static_cast(max - min); // Image range + double scale = 255./diff; // Scale factor + + tmp16 -= min; // Bias + tmp16 *= scale; // Rescale data + + cv::Mat frame8; + tmp16.convertTo( frame8, CV_8UC1 ); + // <<<<< Rescaling/Normalization to 8bit + return frame8; } diff --git a/bbb_life_tracker/test_tracker.cpp b/bbb_life_tracker/test_tracker.cpp new file mode 100644 index 0000000..2088152 --- /dev/null +++ b/bbb_life_tracker/test_tracker.cpp @@ -0,0 +1,65 @@ +#include +#include +#include + +#include +#include + +#include + +#define ROWS 120 +#define COLS 160 + +using namespace std; + +int main( int argc, char* argv[] ) +{ + std::srand(std::time(0)); // use current time as seed for random generator + + cv::Mat test16( ROWS,COLS, CV_16UC1 ); + + uint16_t max_val = static_cast(pow(2,14)-1); + + uint16_t minTh = max_val/8; + uint16_t maxTh = max_val/4; + + for( int r=0; r(std::rand())/RAND_MAX; + + uint16_t rnd_val; + + if( r<90 && r>30 && c<110 && c>50 ) + { + rnd_val = static_cast(minTh+rnd*(maxTh-minTh)); + + } + else + { + rnd_val = static_cast(rnd*max_val); + } + + test16.at(r,c) = rnd_val; + } + } + + cv::Mat resRGB; + + FlirTracker tracker( FlirTracker::TRK_AVOID, minTh, maxTh ); + + if( tracker.setNewFrame( test16, 0, max_val ) != FlirTracker::TRK_RES_ERROR ) + { + resRGB = tracker.getResFrameRGB(); + } + + cv::Mat test8 = FlirTracker::normalizeFrame( test16, 0, max_val ); + + cv::imshow( "Original", test8 ); + cv::imshow( "Result", resRGB ); + + cv::waitKey(); + + return EXIT_SUCCESS; +} diff --git a/grabber_lib/include/Palettes.h b/grabber_lib/include/Palettes.h deleted file mode 100644 index 9fd11a3..0000000 --- a/grabber_lib/include/Palettes.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef PALETTES_H -#define PALETTES_H - -extern const int colormap_rainbow[]; -extern const int colormap_grayscale[]; -extern const int colormap_ironblack[]; -extern const int colormap_blackHot[]; -extern const int colormap_arctic[]; -extern const int colormap_blueRed[]; -extern const int colormap_coldest[]; -extern const int colormap_contrast[]; -extern const int colormap_doubleRainbow[]; -extern const int colormap_grayRed[]; -extern const int colormap_glowBow[]; -extern const int colormap_hottest[]; -extern const int colormap_lava[]; -extern const int colormap_medical[]; -extern const int colormap_wheel2[]; -extern const int colormap_whiteHot[]; - - - -#endif diff --git a/opencv_demo/opencv_demo.cpp b/opencv_demo/opencv_demo.cpp index f72e400..042287a 100755 --- a/opencv_demo/opencv_demo.cpp +++ b/opencv_demo/opencv_demo.cpp @@ -188,7 +188,7 @@ int main (int argc, char *argv[]) frame16.convertTo( frame8, CV_8UC1 ); // <<<<< Rescaling/Normalization to 8bit - cv::cvtColor( frameRGB,frameRGB, CV_GRAY2RGB ); // MPEG needs RGB frames + cv::cvtColor( frame8,frameRGB, CV_GRAY2RGB ); // MPEG needs RGB frames } #ifdef SAVE_MJPEG