├── FlirOneControl ├── iimage.cpp ├── ilanguage.cpp ├── craiifilein.cpp ├── craiifileout.cpp ├── libjpeg │ ├── jversion.h │ ├── rdgif.c │ ├── jconfig.h │ ├── jcomapi.c │ ├── jinclude.h │ ├── jmemansi.c │ ├── cdjpeg.c │ ├── jdtrans.c │ ├── jaricom.c │ ├── cderror.h │ ├── jcapistd.c │ ├── jfdctflt.c │ ├── cdjpeg.h │ ├── jutils.c │ └── rdcolmap.c ├── main.cpp ├── cmutex.h ├── system.h ├── craiicmutex.h ├── tga.h ├── cthread.h ├── craiifilein.h ├── craiifileout.h ├── cmutex.cpp ├── cthread.cpp ├── clabel_imagearea.h ├── clog.h ├── iimage.h ├── cflironedriver.h ├── cdecorator_iimage.h ├── clanguage.h ├── ilanguage.h ├── cpicture.h ├── clanguagerussian.h ├── clanguageenglish.h ├── cdecorator_scale.h ├── cringbuffer.h ├── cgraphics.h ├── clanguage.cpp ├── clog.cpp ├── clabel_imagearea.cpp ├── clanguageenglish.cpp ├── clanguagerussian.cpp ├── cdecorator_iimage.cpp ├── cpicture.cpp ├── FlirOneControl.pro ├── cflironecontrol.h ├── system.cpp ├── cdecorator_scale.cpp ├── cflironereceiver.h ├── cringbuffer.cpp ├── cflironedriver.cpp ├── cmainwindow.h └── cmainwindow.ui ├── .gitignore └── license.txt /FlirOneControl/iimage.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "iimage.h" 5 | -------------------------------------------------------------------------------- /FlirOneControl/ilanguage.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "ilanguage.h" 5 | -------------------------------------------------------------------------------- /FlirOneControl/craiifilein.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | 5 | #include "craiifilein.h" 6 | 7 | -------------------------------------------------------------------------------- /FlirOneControl/craiifileout.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | 5 | #include "craiifileout.h" 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | #Ignore thumbnails created by Windows 3 | Thumbs.db 4 | #Ignore files built by Visual Studio 5 | *.obj 6 | *.exe 7 | *.pdb 8 | *.user 9 | *.aps 10 | *.pch 11 | *.vspscc 12 | *_i.c 13 | *_p.c 14 | *.ncb 15 | *.suo 16 | *.tlb 17 | *.tlh 18 | *.bak 19 | *.cache 20 | *.ilk 21 | *.log 22 | *.o 23 | [Bb]in 24 | [Dd]ebug*/ 25 | *.lib 26 | *.sbr 27 | obj/ 28 | [Rr]elease*/ 29 | _ReSharper*/ 30 | [Tt]est[Rr]esult* 31 | .vs/ 32 | #Nuget packages folder 33 | packages/ 34 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/jversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jversion.h 3 | * 4 | * Copyright (C) 1991-2018, Thomas G. Lane, Guido Vollbeding. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains software version identification. 9 | */ 10 | 11 | 12 | #define JVERSION "9c 14-Jan-2018" 13 | 14 | #define JCOPYRIGHT "Copyright (C) 2018, Thomas G. Lane, Guido Vollbeding" 15 | -------------------------------------------------------------------------------- /FlirOneControl/main.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "cmainwindow.h" 5 | #include 6 | 7 | //**************************************************************************************************** 8 | //главная функция программы 9 | //**************************************************************************************************** 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | QApplication qApplication(argc,argv); 14 | CMainWindow cMainWindow; 15 | cMainWindow.show(); 16 | return(qApplication.exec()); 17 | } 18 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 da-nie 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | 24 | P.S. libjpeg not included in this license. 25 | -------------------------------------------------------------------------------- /FlirOneControl/cmutex.h: -------------------------------------------------------------------------------- 1 | #ifndef C_MUTEX_H 2 | #define C_MUTEX_H 3 | 4 | //**************************************************************************************************** 5 | //Класс работы с мютексом 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include 12 | 13 | //**************************************************************************************************** 14 | //макроопределения 15 | //**************************************************************************************************** 16 | 17 | //**************************************************************************************************** 18 | //Класс работы с мютексом 19 | //**************************************************************************************************** 20 | 21 | class CMutex 22 | { 23 | private: 24 | pthread_mutex_t MutexID;//мьютекс 25 | public: 26 | //конструктор 27 | CMutex(void); 28 | //конструктор копирования 29 | CMutex(const CMutex& cMutex); 30 | //деструктор 31 | ~CMutex(); 32 | public: 33 | void Lock(void);//заблокировать мютекс 34 | void Unlock(void);//разблокировать мютекс 35 | }; 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/rdgif.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rdgif.c 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains routines to read input images in GIF format. 9 | * 10 | ***************************************************************************** 11 | * NOTE: to avoid entanglements with Unisys' patent on LZW compression, * 12 | * the ability to read GIF files has been removed from the IJG distribution. * 13 | * Sorry about that. * 14 | ***************************************************************************** 15 | * 16 | * We are required to state that 17 | * "The Graphics Interchange Format(c) is the Copyright property of 18 | * CompuServe Incorporated. GIF(sm) is a Service Mark property of 19 | * CompuServe Incorporated." 20 | */ 21 | 22 | #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ 23 | 24 | #ifdef GIF_SUPPORTED 25 | 26 | /* 27 | * The module selection routine for GIF format input. 28 | */ 29 | 30 | GLOBAL(cjpeg_source_ptr) 31 | jinit_read_gif (j_compress_ptr cinfo) 32 | { 33 | fprintf(stderr, "GIF input is unsupported for legal reasons. Sorry.\n"); 34 | exit(EXIT_FAILURE); 35 | return NULL; /* keep compiler happy */ 36 | } 37 | 38 | #endif /* GIF_SUPPORTED */ 39 | -------------------------------------------------------------------------------- /FlirOneControl/system.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEM_H 2 | #define SYSTEM_H 3 | 4 | //**************************************************************************************************** 5 | //зависящие от системы функции 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include 12 | #include 13 | 14 | //**************************************************************************************************** 15 | //прототипы функций 16 | //**************************************************************************************************** 17 | 18 | void CreateFileList(const std::string &path,std::vector &vector_file_name);//создать список файлов директории 19 | void CreateDirectoryList(const std::string &path,std::vector &vector_directory_name);//создать список каталогов директории 20 | void MakeDirectory(const std::string &directory_name);//создать каталог 21 | long double GetSecondCounter(void);//получить прошедшее время в секундах 22 | void PauseInMs(size_t ms);//пауза в миллисекундах 23 | void PauseInUs(size_t us);//пауза в микросекундах 24 | std::string GetCurrentPath(void);//получить текущую директорию 25 | std::string GetPathDivider(void);//получить разделитель каталого 26 | void PutMessage(const std::string &message);//вывести сообщение 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /FlirOneControl/craiicmutex.h: -------------------------------------------------------------------------------- 1 | #ifndef C_RAII_CMUTEX_H 2 | #define C_RAII_CMUTEX_H 3 | 4 | //**************************************************************************************************** 5 | //описание 6 | //**************************************************************************************************** 7 | 8 | //Класс RAII для работы с мютексом 9 | 10 | //**************************************************************************************************** 11 | //подключаемые библиотеки 12 | //**************************************************************************************************** 13 | 14 | #include "cmutex.h" 15 | 16 | //**************************************************************************************************** 17 | //класс RAII критической секции 18 | //**************************************************************************************************** 19 | class CRAIICMutex 20 | { 21 | private: 22 | CMutex *cMutex_Ptr;//указатель на мютекс 23 | bool Locked;//состояние мютекса 24 | public: 25 | CRAIICMutex(CMutex *cMutex_Set_Ptr)//конструктор 26 | { 27 | Locked=false; 28 | if (cMutex_Set_Ptr==NULL) return; 29 | cMutex_Ptr=cMutex_Set_Ptr; 30 | 31 | Lock(); 32 | } 33 | ~CRAIICMutex() 34 | { 35 | if (cMutex_Ptr==NULL) return; 36 | Unlock(); 37 | } 38 | void Lock(void) 39 | { 40 | if (cMutex_Ptr==NULL) return; 41 | if (Locked==true) return; 42 | cMutex_Ptr->Lock(); 43 | Locked=true; 44 | } 45 | void Unlock(void) 46 | { 47 | if (cMutex_Ptr==NULL) return; 48 | if (Locked==false) return; 49 | cMutex_Ptr->Unlock(); 50 | Locked=false; 51 | } 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /FlirOneControl/tga.h: -------------------------------------------------------------------------------- 1 | #ifndef TGA_H 2 | #define TGA_H 3 | 4 | //==================================================================================================== 5 | //подключаемые библиотеки 6 | //==================================================================================================== 7 | 8 | #include 9 | #include 10 | 11 | //==================================================================================================== 12 | //структуры 13 | //==================================================================================================== 14 | 15 | //заголовок TGA-файла 16 | #pragma pack(1) 17 | struct STGAHeader 18 | { 19 | uint8_t identsize;//размер поля заголовка 20 | uint8_t colorMapType;//если ли палитра:0-нет,1-есть 21 | uint8_t imageType;//тип картинки:0-нет,1-индексные цвета,2-RGB,3-оттенки серого, (3-й бит - RLE- кодирование) 22 | uint16_t colorMapStart;//начало карты цветов 23 | uint16_t colorMapLength;//количество цветов в карте 24 | uint8_t colorMapBits;//размерность палитры 25 | uint16_t xstart;//начальные координаты изображения 26 | uint16_t ystart; 27 | uint16_t width;//размер изображения по X 28 | uint16_t height;//размер изображения по Y 29 | uint8_t bits;//количесто бит на пиксель (8,16,24,32) 30 | uint8_t descriptor;//дескриптор изрображения 31 | }; 32 | #pragma pack() 33 | 34 | //==================================================================================================== 35 | //прототипы функций 36 | //==================================================================================================== 37 | 38 | uint8_t *LoadTGAFromFile(const char *file_name,int32_t &width,int32_t &height);//загрузить tga-файл 39 | bool SaveTGA(const char *file_name,int32_t width,int32_t height,uint8_t *image);//сохранить картинку в tga-файл 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /FlirOneControl/cthread.h: -------------------------------------------------------------------------------- 1 | #ifndef C_THREAD_H 2 | #define C_THREAD_H 3 | 4 | //**************************************************************************************************** 5 | //Класс работы с потоками 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include 12 | #include 13 | 14 | //**************************************************************************************************** 15 | //прототипы функций 16 | //**************************************************************************************************** 17 | 18 | //**************************************************************************************************** 19 | //Класс работы с потоками 20 | //**************************************************************************************************** 21 | 22 | class CThread 23 | { 24 | //-переменные----------------------------------------------------------------------------------------- 25 | private: 26 | pthread_t pthread_ID;//идентификатор потока 27 | //-конструктор---------------------------------------------------------------------------------------- 28 | public: 29 | CThread(void* (*start_routine)(void*),void *param); 30 | CThread(void); 31 | //-деструктор----------------------------------------------------------------------------------------- 32 | ~CThread(); 33 | //-открытые функции----------------------------------------------------------------------------------- 34 | public: 35 | void Create(void* (*start_routine)(void*),void *param);//создать поток 36 | void Join(void);//ждать завершения потока 37 | }; 38 | #endif 39 | 40 | -------------------------------------------------------------------------------- /FlirOneControl/craiifilein.h: -------------------------------------------------------------------------------- 1 | #ifndef C_RAII_FILE_IN_H 2 | #define C_RAII_FILE_IN_H 3 | //**************************************************************************************************** 4 | //класс работы с файлами с использованием концепции RAII 5 | //**************************************************************************************************** 6 | 7 | //**************************************************************************************************** 8 | //подключаемые библиотеки 9 | //**************************************************************************************************** 10 | #include 11 | #include 12 | #include 13 | 14 | //**************************************************************************************************** 15 | //класс работы с файлами с использованием концепции RAII 16 | //**************************************************************************************************** 17 | class CRAIIFileIn 18 | { 19 | private: 20 | std::ifstream File; 21 | std::string FileName;//имя файла 22 | public: 23 | //конструктор 24 | CRAIIFileIn(const std::string &file_name,std::ios_base::openmode mode):FileName(file_name) 25 | { 26 | File.open(file_name.c_str(),mode); 27 | } 28 | //деструктор 29 | ~CRAIIFileIn(void) 30 | { 31 | Close(); 32 | } 33 | //получить класс файла 34 | std::ifstream& GetHandle(void) 35 | { 36 | return(File); 37 | } 38 | //узнать, открыт ли файл 39 | bool IsOpened(void) 40 | { 41 | return(File.is_open()); 42 | } 43 | //получить имя файла 44 | std::string& GetFileName(void) 45 | { 46 | return(FileName); 47 | } 48 | //закрыть файл 49 | void Close(void) 50 | { 51 | File.close(); 52 | } 53 | //открыть файл 54 | void Open(const std::string &file_name,std::ios_base::openmode mode) 55 | { 56 | Close(); 57 | FileName=file_name; 58 | File.open(file_name.c_str(),mode); 59 | } 60 | }; 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/jconfig.h: -------------------------------------------------------------------------------- 1 | /* jconfig.h. Generated from jconfig.cfg by configure. */ 2 | /* jconfig.cfg --- source file edited by configure script */ 3 | /* see jconfig.txt for explanations */ 4 | 5 | #define HAVE_PROTOTYPES 1 6 | #define HAVE_UNSIGNED_CHAR 1 7 | #define HAVE_UNSIGNED_SHORT 1 8 | /* #undef void */ 9 | /* #undef const */ 10 | /* #undef CHAR_IS_UNSIGNED */ 11 | #define HAVE_STDDEF_H 1 12 | #define HAVE_STDLIB_H 1 13 | #define HAVE_LOCALE_H 1 14 | /* #undef NEED_BSD_STRINGS */ 15 | /* #undef NEED_SYS_TYPES_H */ 16 | /* #undef NEED_FAR_POINTERS */ 17 | /* #undef NEED_SHORT_EXTERNAL_NAMES */ 18 | /* Define this if you get warnings about undefined structures. */ 19 | /* #undef INCOMPLETE_TYPES_BROKEN */ 20 | 21 | /* Define "boolean" as unsigned char, not enum, on Windows systems. */ 22 | #ifdef _WIN32 23 | #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ 24 | typedef unsigned char boolean; 25 | #endif 26 | #ifndef FALSE /* in case these macros already exist */ 27 | #define FALSE 0 /* values of boolean */ 28 | #endif 29 | #ifndef TRUE 30 | #define TRUE 1 31 | #endif 32 | #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ 33 | #endif 34 | 35 | #ifdef JPEG_INTERNALS 36 | 37 | /* #undef RIGHT_SHIFT_IS_UNSIGNED */ 38 | #define INLINE __inline__ 39 | /* These are for configuring the JPEG memory manager. */ 40 | /* #undef DEFAULT_MAX_MEM */ 41 | /* #undef NO_MKTEMP */ 42 | 43 | #endif /* JPEG_INTERNALS */ 44 | 45 | #ifdef JPEG_CJPEG_DJPEG 46 | 47 | #define BMP_SUPPORTED /* BMP image file format */ 48 | #define GIF_SUPPORTED /* GIF image file format */ 49 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ 50 | /* #undef RLE_SUPPORTED */ 51 | #define TARGA_SUPPORTED /* Targa image file format */ 52 | 53 | /* #undef TWO_FILE_COMMANDLINE */ 54 | /* #undef NEED_SIGNAL_CATCHER */ 55 | /* #undef DONT_USE_B_MODE */ 56 | 57 | /* Define this if you want percent-done progress reports from cjpeg/djpeg. */ 58 | /* #undef PROGRESS_REPORT */ 59 | 60 | #endif /* JPEG_CJPEG_DJPEG */ 61 | -------------------------------------------------------------------------------- /FlirOneControl/craiifileout.h: -------------------------------------------------------------------------------- 1 | #ifndef C_RAII_FILE_OUT_H 2 | #define C_RAII_FILE_OUT_H 3 | //**************************************************************************************************** 4 | //класс работы с файлами с использованием концепции RAII 5 | //**************************************************************************************************** 6 | 7 | //**************************************************************************************************** 8 | //подключаемые библиотеки 9 | //**************************************************************************************************** 10 | #include 11 | #include 12 | #include 13 | 14 | //**************************************************************************************************** 15 | //класс работы с файлами с использованием концепции RAII 16 | //**************************************************************************************************** 17 | class CRAIIFileOut 18 | { 19 | private: 20 | std::ofstream File; 21 | std::string FileName;//имя файла 22 | public: 23 | //конструктор 24 | CRAIIFileOut(void) 25 | { 26 | } 27 | //конструктор 28 | CRAIIFileOut(const std::string &file_name,std::ios_base::openmode mode):FileName(file_name) 29 | { 30 | File.open(file_name.c_str(),mode); 31 | } 32 | //деструктор 33 | ~CRAIIFileOut(void) 34 | { 35 | Close(); 36 | } 37 | //получить класс файла 38 | std::ofstream& GetHandle(void) 39 | { 40 | return(File); 41 | } 42 | //узнать, открыт ли файл 43 | bool IsOpened(void) 44 | { 45 | return(File.is_open()); 46 | } 47 | //получить имя файла 48 | std::string& GetFileName(void) 49 | { 50 | return(FileName); 51 | } 52 | //закрыть файл 53 | void Close(void) 54 | { 55 | FileName=""; 56 | File.close(); 57 | } 58 | //открыть файл 59 | void Open(const std::string &file_name,std::ios_base::openmode mode) 60 | { 61 | Close(); 62 | FileName=file_name; 63 | File.open(file_name.c_str(),mode); 64 | } 65 | }; 66 | 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /FlirOneControl/cmutex.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "cmutex.h" 5 | 6 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | //конструктор и деструктор класса 8 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 | 10 | //---------------------------------------------------------------------------------------------------- 11 | //конструктор 12 | //---------------------------------------------------------------------------------------------------- 13 | CMutex::CMutex(void) 14 | { 15 | pthread_mutex_init(&MutexID,NULL); 16 | } 17 | //---------------------------------------------------------------------------------------------------- 18 | //конструктор копирования 19 | //---------------------------------------------------------------------------------------------------- 20 | CMutex::CMutex(const CMutex& cMutex) 21 | { 22 | //нам нужно создать новый мютекс 23 | pthread_mutex_init(&MutexID,NULL); 24 | } 25 | //---------------------------------------------------------------------------------------------------- 26 | //деструктор 27 | //---------------------------------------------------------------------------------------------------- 28 | CMutex::~CMutex() 29 | { 30 | pthread_mutex_destroy(&MutexID); 31 | } 32 | 33 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 34 | //закрытые функции класса 35 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 36 | 37 | //---------------------------------------------------------------------------------------------------- 38 | //заблокировать мютекс 39 | //---------------------------------------------------------------------------------------------------- 40 | void CMutex::Lock(void) 41 | { 42 | pthread_mutex_lock(&MutexID); 43 | } 44 | //---------------------------------------------------------------------------------------------------- 45 | //разблокировать мютекс 46 | //---------------------------------------------------------------------------------------------------- 47 | void CMutex::Unlock(void) 48 | { 49 | pthread_mutex_unlock(&MutexID); 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /FlirOneControl/cthread.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "cthread.h" 5 | 6 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 | //конструктор и деструктор класса 8 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 | 10 | //---------------------------------------------------------------------------------------------------- 11 | //конструктор 12 | //---------------------------------------------------------------------------------------------------- 13 | CThread::CThread(void* (*start_routine)(void*),void *param) 14 | { 15 | Create(start_routine,param); 16 | } 17 | //---------------------------------------------------------------------------------------------------- 18 | //конструктор 19 | //---------------------------------------------------------------------------------------------------- 20 | CThread::CThread(void) 21 | { 22 | pthread_ID=-1; 23 | } 24 | //---------------------------------------------------------------------------------------------------- 25 | //деструктор 26 | //---------------------------------------------------------------------------------------------------- 27 | CThread::~CThread() 28 | { 29 | Join(); 30 | } 31 | 32 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 33 | //закрытые функции класса 34 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 35 | 36 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 37 | //открытые функции класса 38 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 39 | 40 | //---------------------------------------------------------------------------------------------------- 41 | //создать поток 42 | //---------------------------------------------------------------------------------------------------- 43 | void CThread::Create(void* (*start_routine)(void*),void *param) 44 | { 45 | //запускаем поток 46 | pthread_attr_t pt_attr; 47 | pthread_attr_init(&pt_attr); 48 | pthread_attr_setdetachstate(&pt_attr,PTHREAD_CREATE_JOINABLE); 49 | //pthread_attr_setinheritsched(&pt_attr,PTHREAD_EXPLICIT_SCHED); 50 | //pthread_attr_setschedpolicy(&pt_attr,SCHED_RR); 51 | pthread_create(&pthread_ID,&pt_attr,start_routine,param);//создаём поток 52 | } 53 | 54 | //---------------------------------------------------------------------------------------------------- 55 | //ждать завершения потока 56 | //---------------------------------------------------------------------------------------------------- 57 | void CThread::Join(void) 58 | { 59 | if (pthread_ID!=-1) pthread_join(pthread_ID,NULL);//;ждём завершения потока 60 | pthread_ID=-1; 61 | } 62 | -------------------------------------------------------------------------------- /FlirOneControl/clabel_imagearea.h: -------------------------------------------------------------------------------- 1 | #ifndef C_LABEL_IMAGE_AREA_H 2 | #define C_LABEL_IMAGE_AREA_H 3 | 4 | //**************************************************************************************************** 5 | //класс отображения изображений 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include 12 | 13 | //**************************************************************************************************** 14 | //макроопределения 15 | //**************************************************************************************************** 16 | 17 | //**************************************************************************************************** 18 | //константы 19 | //**************************************************************************************************** 20 | 21 | //**************************************************************************************************** 22 | //предварительные объявления 23 | //**************************************************************************************************** 24 | 25 | //**************************************************************************************************** 26 | //класс отображения изображений 27 | //**************************************************************************************************** 28 | class CLabel_ImageArea:public QLabel 29 | { 30 | Q_OBJECT 31 | public: 32 | //-перечисления--------------------------------------------------------------------------------------- 33 | //-структуры------------------------------------------------------------------------------------------ 34 | private: 35 | //-константы------------------------------------------------------------------------------------------ 36 | private: 37 | //-переменные----------------------------------------------------------------------------------------- 38 | QImage qImage;//выводимое изображение 39 | public: 40 | //-конструктор---------------------------------------------------------------------------------------- 41 | explicit CLabel_ImageArea(uint32_t width,uint32_t height,QWidget *parent=NULL); 42 | //-деструктор----------------------------------------------------------------------------------------- 43 | ~CLabel_ImageArea(); 44 | public: 45 | //-открытые функции----------------------------------------------------------------------------------- 46 | void Redraw(const uint32_t *image_data);//заменить изображение 47 | private: 48 | //-закрытые функции----------------------------------------------------------------------------------- 49 | void paintEvent(QPaintEvent *qPaintEvent_Ptr);//обработчик события перерисовки 50 | //-слоты---------------------------------------------------------------------------------------------- 51 | public slots: 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /FlirOneControl/clog.h: -------------------------------------------------------------------------------- 1 | #ifndef C_LOG_H 2 | #define C_LOG_H 3 | 4 | //**************************************************************************************************** 5 | //Класс вывода работы программы 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include 12 | #include 13 | 14 | //**************************************************************************************************** 15 | //макроопределения 16 | //**************************************************************************************************** 17 | 18 | //**************************************************************************************************** 19 | //константы 20 | //**************************************************************************************************** 21 | 22 | //**************************************************************************************************** 23 | //предварительные объявления 24 | //**************************************************************************************************** 25 | 26 | //**************************************************************************************************** 27 | //Класс вывода работы программы 28 | //**************************************************************************************************** 29 | class CLog 30 | { 31 | public: 32 | //-перечисления--------------------------------------------------------------------------------------- 33 | //-структуры------------------------------------------------------------------------------------------ 34 | //-константы------------------------------------------------------------------------------------------ 35 | private: 36 | //-переменные----------------------------------------------------------------------------------------- 37 | static std::unique_ptr cLog_Ptr;//указатель на класс вывода работы программы 38 | private: 39 | //-конструктор---------------------------------------------------------------------------------------- 40 | CLog(void); 41 | public: 42 | //-деструктор----------------------------------------------------------------------------------------- 43 | ~CLog(); 44 | public: 45 | //-статические открытые функции----------------------------------------------------------------------- 46 | static CLog* GetPtr(void);//получить указатель на класс вывода работы программы 47 | //-открытые функции----------------------------------------------------------------------------------- 48 | void AddLog(const std::string &string);//добавить строку в log-файл 49 | void AddLog(int32_t value);//добавить число в log-файл 50 | private: 51 | //-закрытые функции----------------------------------------------------------------------------------- 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /FlirOneControl/iimage.h: -------------------------------------------------------------------------------- 1 | #ifndef I_IMAGE_H 2 | #define I_IMAGE_H 3 | 4 | //**************************************************************************************************** 5 | //Интерфейс к изображению 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include 12 | #include 13 | 14 | //**************************************************************************************************** 15 | //макроопределения 16 | //**************************************************************************************************** 17 | 18 | //**************************************************************************************************** 19 | //константы 20 | //**************************************************************************************************** 21 | 22 | //**************************************************************************************************** 23 | //предварительные объявления 24 | //**************************************************************************************************** 25 | 26 | //**************************************************************************************************** 27 | //Интерфейс к изображению 28 | //**************************************************************************************************** 29 | class IImage 30 | { 31 | public: 32 | //-перечисления--------------------------------------------------------------------------------------- 33 | //-структуры------------------------------------------------------------------------------------------ 34 | //-константы------------------------------------------------------------------------------------------ 35 | private: 36 | //-переменные----------------------------------------------------------------------------------------- 37 | public: 38 | //-деструктор----------------------------------------------------------------------------------------- 39 | virtual ~IImage() {} 40 | public: 41 | //-открытые функции----------------------------------------------------------------------------------- 42 | virtual void GetRGBAImage(uint32_t &width,uint32_t &height,std::vector &vector_image)=0;//получить изображение в формате RGBA 43 | virtual void SetRGBAImage(const uint32_t &width,const uint32_t &height,const std::vector &vector_image)=0;//задать изображение в формате RGBA 44 | virtual void SetSize(uint32_t width,uint32_t height)=0;//задать размер изображения и выделить память 45 | virtual void SetRGBAPixel(uint32_t x,uint32_t y,uint32_t color)=0;//задать точку 46 | virtual uint32_t GetRGBAPixel(uint32_t x,uint32_t y)=0;//получить точку 47 | //-открытые статические функции----------------------------------------------------------------------- 48 | }; 49 | 50 | 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /FlirOneControl/cflironedriver.h: -------------------------------------------------------------------------------- 1 | #ifndef C_FLIR_ONE_DRIVER_H 2 | #define C_FLIR_ONE_DRIVER_H 3 | 4 | //**************************************************************************************************** 5 | //Класс подключения к драйверам Flir One 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include 12 | #include "libusb.h" 13 | 14 | //**************************************************************************************************** 15 | //макроопределения 16 | //**************************************************************************************************** 17 | 18 | //**************************************************************************************************** 19 | //константы 20 | //**************************************************************************************************** 21 | 22 | //**************************************************************************************************** 23 | //предварительные объявления 24 | //**************************************************************************************************** 25 | 26 | //**************************************************************************************************** 27 | //Класс подключения к драйверам Flir One 28 | //**************************************************************************************************** 29 | class CFlirOneDriver 30 | { 31 | public: 32 | //-перечисления--------------------------------------------------------------------------------------- 33 | //-структуры------------------------------------------------------------------------------------------ 34 | //-константы------------------------------------------------------------------------------------------ 35 | static const size_t VENDOR_ID=0x09cb;//идентификатор производителя 36 | static const size_t PRODUCT_ID=0x1996;//индентификатор устройства 37 | private: 38 | //-переменные----------------------------------------------------------------------------------------- 39 | libusb_device_handle *USBDeviceHandle;//дескриптор устройства 40 | bool Ready;//готовность к приёму данных 41 | public: 42 | //-конструктор---------------------------------------------------------------------------------------- 43 | CFlirOneDriver(void); 44 | //-деструктор----------------------------------------------------------------------------------------- 45 | ~CFlirOneDriver(); 46 | public: 47 | //-открытые функции----------------------------------------------------------------------------------- 48 | bool Open(void);//подключиться к устройству 49 | void Close(void);//отключиться от устройства 50 | bool ReadStream(uint8_t* ptr,uint32_t &size);//чтение данных из устройств 51 | private: 52 | //-закрытые функции----------------------------------------------------------------------------------- 53 | bool InitFlirOne(void);//инициализация Flir One 54 | bool ConnectToFlirOne(void);//подключение к Flir One 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /FlirOneControl/cdecorator_iimage.h: -------------------------------------------------------------------------------- 1 | #ifndef C_DECORATOR__I_IMAGE_H 2 | #define C_DECORATOR__I_IMAGE_H 3 | 4 | //**************************************************************************************************** 5 | //Декоратор для IImage 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include "iimage.h" 12 | #include 13 | #include 14 | 15 | //**************************************************************************************************** 16 | //макроопределения 17 | //**************************************************************************************************** 18 | 19 | //**************************************************************************************************** 20 | //константы 21 | //**************************************************************************************************** 22 | 23 | //**************************************************************************************************** 24 | //предварительные объявления 25 | //**************************************************************************************************** 26 | 27 | //**************************************************************************************************** 28 | //Декоратор для IImage 29 | //**************************************************************************************************** 30 | class CDecorator_IImage:public IImage 31 | { 32 | public: 33 | //-перечисления--------------------------------------------------------------------------------------- 34 | //-структуры------------------------------------------------------------------------------------------ 35 | //-константы------------------------------------------------------------------------------------------ 36 | private: 37 | //-переменные----------------------------------------------------------------------------------------- 38 | IImage *iImage_Ptr; 39 | public: 40 | //-конструктор---------------------------------------------------------------------------------------- 41 | CDecorator_IImage(IImage *iImage_Set_Ptr); 42 | //-деструктор----------------------------------------------------------------------------------------- 43 | ~CDecorator_IImage(); 44 | public: 45 | //-открытые функции----------------------------------------------------------------------------------- 46 | void GetRGBAImage(uint32_t &width,uint32_t &height,std::vector &vector_image);//получить RGBA изображение 47 | void SetRGBAImage(const uint32_t &width,const uint32_t &height,const std::vector &vector_image);//задать RGBA изображение 48 | void SetSize(uint32_t width,uint32_t height);//задать размер изображения и выделить память 49 | void SetRGBAPixel(uint32_t x,uint32_t y,uint32_t color);//задать точку 50 | uint32_t GetRGBAPixel(uint32_t x,uint32_t y);//получить точку 51 | private: 52 | //-закрытые функции----------------------------------------------------------------------------------- 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /FlirOneControl/clanguage.h: -------------------------------------------------------------------------------- 1 | #ifndef C_LANGUAGE_H 2 | #define C_LANGUAGE_H 3 | 4 | //**************************************************************************************************** 5 | //Строки для различных языков 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include 12 | #include 13 | #include "ilanguage.h" 14 | 15 | //**************************************************************************************************** 16 | //макроопределения 17 | //**************************************************************************************************** 18 | 19 | //**************************************************************************************************** 20 | //константы 21 | //**************************************************************************************************** 22 | 23 | //**************************************************************************************************** 24 | //предварительные объявления 25 | //**************************************************************************************************** 26 | 27 | //**************************************************************************************************** 28 | //Строки для различных языков 29 | //**************************************************************************************************** 30 | class CLanguage 31 | { 32 | public: 33 | //-перечисления--------------------------------------------------------------------------------------- 34 | enum LANGUAGE 35 | { 36 | LANGUAGE_RUSSIAN=0,//русский язык 37 | LANGUAGE_ENGLISH//английский язык 38 | }; 39 | //-структуры------------------------------------------------------------------------------------------ 40 | //-константы------------------------------------------------------------------------------------------ 41 | private: 42 | //-переменные----------------------------------------------------------------------------------------- 43 | static std::unique_ptr cLanguage_Ptr;//указатель на класс сообщений 44 | static std::unique_ptr iLanguage_Ptr;//указатель на класс сообщений на выбранном языке 45 | LANGUAGE SelectedLanguage;//выбранный язык сообщений 46 | private: 47 | //-конструктор---------------------------------------------------------------------------------------- 48 | CLanguage(void); 49 | public: 50 | //-деструктор----------------------------------------------------------------------------------------- 51 | ~CLanguage(); 52 | public: 53 | //-открытые функции----------------------------------------------------------------------------------- 54 | static CLanguage* GetPtr(void);//получить указатель на класс сообщений 55 | ILanguage* GetTextPtr(void);//получить указатель на класс сообщений на выбранном языке 56 | void SetLanguage(LANGUAGE language);//задать язык 57 | private: 58 | //-закрытые функции----------------------------------------------------------------------------------- 59 | }; 60 | #endif 61 | -------------------------------------------------------------------------------- /FlirOneControl/ilanguage.h: -------------------------------------------------------------------------------- 1 | #ifndef I_LANGUAGE_H 2 | #define I_LANGUAGE_H 3 | 4 | //**************************************************************************************************** 5 | //Интерфейс класса сообщений 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include 12 | 13 | //**************************************************************************************************** 14 | //макроопределения 15 | //**************************************************************************************************** 16 | 17 | //**************************************************************************************************** 18 | //константы 19 | //**************************************************************************************************** 20 | 21 | //**************************************************************************************************** 22 | //предварительные объявления 23 | //**************************************************************************************************** 24 | 25 | //**************************************************************************************************** 26 | //Интерфейс класса сообщений 27 | //**************************************************************************************************** 28 | class ILanguage 29 | { 30 | public: 31 | //-перечисления--------------------------------------------------------------------------------------- 32 | //-структуры------------------------------------------------------------------------------------------ 33 | //-константы------------------------------------------------------------------------------------------ 34 | private: 35 | //-переменные----------------------------------------------------------------------------------------- 36 | public: 37 | //-деструктор----------------------------------------------------------------------------------------- 38 | virtual ~ILanguage() {} 39 | public: 40 | //-открытые функции----------------------------------------------------------------------------------- 41 | virtual std::string WindowTitle(void)=0; 42 | virtual std::string Label_Emission(void)=0; 43 | virtual std::string Label_Temper(void)=0; 44 | virtual std::string Label_Palette(void)=0; 45 | virtual std::string Label_Alarm(void)=0; 46 | virtual std::string Button_ApplyPalette(void)=0; 47 | virtual std::string Button_ShowVideo(void)=0; 48 | virtual std::string Button_SaveImageCross(void)=0; 49 | virtual std::string Button_SaveImageNoScale(void)=0; 50 | virtual std::string Button_SaveRAW(void)=0; 51 | virtual std::string Button_SaveVideo(void)=0; 52 | virtual std::string Button_SaveAllFrame(void)=0; 53 | virtual std::string Button_SaveFrame(void)=0; 54 | virtual std::string Label_LevelMinT(void)=0; 55 | virtual std::string Label_LevelMaxT(void)=0; 56 | virtual std::string CheckBox_SaveFrame(void)=0; 57 | //-открытые статические функции----------------------------------------------------------------------- 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /FlirOneControl/cpicture.h: -------------------------------------------------------------------------------- 1 | #ifndef C_PICTURE_H 2 | #define C_PICTURE_H 3 | 4 | //**************************************************************************************************** 5 | //Класс простого изображения 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include "iimage.h" 12 | #include 13 | #include 14 | 15 | //**************************************************************************************************** 16 | //макроопределения 17 | //**************************************************************************************************** 18 | 19 | //**************************************************************************************************** 20 | //константы 21 | //**************************************************************************************************** 22 | 23 | //**************************************************************************************************** 24 | //предварительные объявления 25 | //**************************************************************************************************** 26 | 27 | //**************************************************************************************************** 28 | //Класс простого изображения 29 | //**************************************************************************************************** 30 | class CPicture:public IImage 31 | { 32 | public: 33 | //-перечисления--------------------------------------------------------------------------------------- 34 | //-структуры------------------------------------------------------------------------------------------ 35 | //-константы------------------------------------------------------------------------------------------ 36 | private: 37 | //-переменные----------------------------------------------------------------------------------------- 38 | uint32_t Width;//ширина 39 | uint32_t Height;//высота 40 | std::vector vector_Image;//данные изображения 41 | public: 42 | //-конструктор---------------------------------------------------------------------------------------- 43 | CPicture(void); 44 | //-деструктор----------------------------------------------------------------------------------------- 45 | ~CPicture(); 46 | public: 47 | //-открытые функции----------------------------------------------------------------------------------- 48 | void GetRGBAImage(uint32_t &width,uint32_t &height,std::vector &vector_image);//получить изображение в формате RGBA 49 | void SetRGBAImage(const uint32_t &width,const uint32_t &height,const std::vector &vector_image);//задать изображение в формате RGBA 50 | void SetSize(uint32_t width,uint32_t height);//задать размер изображения и выделить память 51 | void SetRGBAPixel(uint32_t x,uint32_t y,uint32_t color);//задать точку 52 | uint32_t GetRGBAPixel(uint32_t x,uint32_t y);//получить точку 53 | private: 54 | //-закрытые функции----------------------------------------------------------------------------------- 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /FlirOneControl/clanguagerussian.h: -------------------------------------------------------------------------------- 1 | #ifndef C_LANGUAGE_RUSSIAN_H 2 | #define C_LANGUAGE_RUSSIAN_H 3 | 4 | //**************************************************************************************************** 5 | //Сообшения на русском языке 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include "ilanguage.h" 12 | 13 | //**************************************************************************************************** 14 | //макроопределения 15 | //**************************************************************************************************** 16 | 17 | //**************************************************************************************************** 18 | //константы 19 | //**************************************************************************************************** 20 | 21 | //**************************************************************************************************** 22 | //предварительные объявления 23 | //**************************************************************************************************** 24 | 25 | //**************************************************************************************************** 26 | //Сообшения на русском языке 27 | //**************************************************************************************************** 28 | class CLanguageRussian:public ILanguage 29 | { 30 | public: 31 | //-перечисления--------------------------------------------------------------------------------------- 32 | //-структуры------------------------------------------------------------------------------------------ 33 | //-константы------------------------------------------------------------------------------------------ 34 | private: 35 | //-переменные----------------------------------------------------------------------------------------- 36 | public: 37 | //-конструктор---------------------------------------------------------------------------------------- 38 | CLanguageRussian(void); 39 | //-деструктор----------------------------------------------------------------------------------------- 40 | ~CLanguageRussian(); 41 | public: 42 | //-открытые функции----------------------------------------------------------------------------------- 43 | std::string WindowTitle(void); 44 | std::string Label_Emission(void); 45 | std::string Label_Temper(void); 46 | std::string Label_Palette(void); 47 | std::string Label_Alarm(void); 48 | std::string Button_ApplyPalette(void); 49 | std::string Button_ShowVideo(void); 50 | std::string Button_SaveImageCross(void); 51 | std::string Button_SaveImageNoScale(void); 52 | std::string Button_SaveRAW(void); 53 | std::string Button_SaveVideo(void); 54 | std::string Button_SaveAllFrame(void); 55 | std::string Button_SaveFrame(void); 56 | std::string Label_LevelMinT(void); 57 | std::string Label_LevelMaxT(void); 58 | std::string CheckBox_SaveFrame(void); 59 | private: 60 | //-закрытые функции----------------------------------------------------------------------------------- 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /FlirOneControl/clanguageenglish.h: -------------------------------------------------------------------------------- 1 | #ifndef C_LANGUAGE_ENGLISH_H 2 | #define C_LANGUAGE_ENGLISH_H 3 | 4 | //**************************************************************************************************** 5 | //Сообшения на английском языке 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include "ilanguage.h" 12 | 13 | //**************************************************************************************************** 14 | //макроопределения 15 | //**************************************************************************************************** 16 | 17 | //**************************************************************************************************** 18 | //константы 19 | //**************************************************************************************************** 20 | 21 | //**************************************************************************************************** 22 | //предварительные объявления 23 | //**************************************************************************************************** 24 | 25 | //**************************************************************************************************** 26 | //Сообшения на английском языке 27 | //**************************************************************************************************** 28 | class CLanguageEnglish:public ILanguage 29 | { 30 | public: 31 | //-перечисления--------------------------------------------------------------------------------------- 32 | //-структуры------------------------------------------------------------------------------------------ 33 | //-константы------------------------------------------------------------------------------------------ 34 | private: 35 | //-переменные----------------------------------------------------------------------------------------- 36 | public: 37 | //-конструктор---------------------------------------------------------------------------------------- 38 | CLanguageEnglish(void); 39 | //-деструктор----------------------------------------------------------------------------------------- 40 | ~CLanguageEnglish(); 41 | public: 42 | //-открытые функции----------------------------------------------------------------------------------- 43 | std::string WindowTitle(void); 44 | std::string Label_Emission(void); 45 | std::string Label_Temper(void); 46 | std::string Label_Palette(void); 47 | std::string Label_Alarm(void); 48 | std::string Button_ApplyPalette(void); 49 | std::string Button_ShowVideo(void); 50 | std::string Button_SaveImageCross(void); 51 | std::string Button_SaveImageNoScale(void); 52 | std::string Button_SaveRAW(void); 53 | std::string Button_SaveVideo(void); 54 | std::string Button_SaveAllFrame(void); 55 | std::string Button_SaveFrame(void); 56 | std::string Label_LevelMinT(void); 57 | std::string Label_LevelMaxT(void); 58 | std::string CheckBox_SaveFrame(void); 59 | private: 60 | //-закрытые функции----------------------------------------------------------------------------------- 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /FlirOneControl/cdecorator_scale.h: -------------------------------------------------------------------------------- 1 | #ifndef C_DECORATOR__SCALE_H 2 | #define C_DECORATOR__SCALE_H 3 | 4 | //**************************************************************************************************** 5 | //Декоратор для изменения размеров изображения с использованием билинейной интерполяции 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include "cdecorator_iimage.h" 12 | #include 13 | 14 | //**************************************************************************************************** 15 | //макроопределения 16 | //**************************************************************************************************** 17 | 18 | //**************************************************************************************************** 19 | //константы 20 | //**************************************************************************************************** 21 | 22 | //**************************************************************************************************** 23 | //предварительные объявления 24 | //**************************************************************************************************** 25 | 26 | //**************************************************************************************************** 27 | //Декоратор для изменения размеров изображения с использованием билинейной интерполяции 28 | //**************************************************************************************************** 29 | class CDecorator_Scale:public CDecorator_IImage 30 | { 31 | public: 32 | //-перечисления--------------------------------------------------------------------------------------- 33 | //-структуры------------------------------------------------------------------------------------------ 34 | //-константы------------------------------------------------------------------------------------------ 35 | private: 36 | //-переменные----------------------------------------------------------------------------------------- 37 | uint32_t Width;//ширина 38 | uint32_t Height;//высота 39 | public: 40 | //-конструктор---------------------------------------------------------------------------------------- 41 | CDecorator_Scale(IImage *iImage_Set_Ptr,uint32_t new_width,uint32_t new_height); 42 | //-деструктор----------------------------------------------------------------------------------------- 43 | ~CDecorator_Scale(); 44 | public: 45 | //-открытые функции----------------------------------------------------------------------------------- 46 | void GetRGBAImage(uint32_t &width,uint32_t &height,std::vector &vector_image);//получить RGBA изображение 47 | void SetRGBAImage(const uint32_t &width,const uint32_t &height,const std::vector &vector_image);//задать RGBA изображение 48 | void SetSize(uint32_t width,uint32_t height);//задать размер изображения и выделить память 49 | void SetRGBAPixel(uint32_t x,uint32_t y,uint32_t color);//задать точку 50 | uint32_t GetRGBAPixel(uint32_t x,uint32_t y);//получить точку 51 | private: 52 | //-закрытые функции----------------------------------------------------------------------------------- 53 | }; 54 | 55 | 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /FlirOneControl/cringbuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef C_RING_BUFFER_H 2 | #define C_RING_BUFFER_H 3 | 4 | //**************************************************************************************************** 5 | //Класс кольцевого буфера 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include 12 | 13 | //**************************************************************************************************** 14 | //макроопределения 15 | //**************************************************************************************************** 16 | 17 | //**************************************************************************************************** 18 | //константы 19 | //**************************************************************************************************** 20 | 21 | //**************************************************************************************************** 22 | //предварительные объявления 23 | //**************************************************************************************************** 24 | 25 | //**************************************************************************************************** 26 | //Класс кольцевого буфера 27 | //**************************************************************************************************** 28 | class CRingBuffer 29 | { 30 | public: 31 | //-перечисления--------------------------------------------------------------------------------------- 32 | //-структуры------------------------------------------------------------------------------------------ 33 | //-константы------------------------------------------------------------------------------------------ 34 | private: 35 | //-переменные----------------------------------------------------------------------------------------- 36 | uint8_t *Buffer;//буфер данных 37 | uint32_t Head;//голова в буфере 38 | uint32_t Tail;//хвост в буфере 39 | uint32_t Size;//размер буфера 40 | public: 41 | //-конструктор---------------------------------------------------------------------------------------- 42 | CRingBuffer(uint32_t size); 43 | //-деструктор----------------------------------------------------------------------------------------- 44 | ~CRingBuffer(); 45 | public: 46 | //-открытые функции----------------------------------------------------------------------------------- 47 | void PushByte(uint8_t b);//добавить байт в кольцевой буфер 48 | bool PopByte(uint8_t *b);//забрать байт из кольцевого буфера 49 | bool PopShort(uint16_t *s);//забрать два байта из кольцевого буфера 50 | uint32_t GetDataSize(void) const;//получить сколько байт в кольцевом буфере 51 | uint32_t GetHeadPos(void) const;//получить позицию головы буфера 52 | uint32_t GetTailPos(void) const;//получить позицию хвоста буфера 53 | uint32_t GetBufferSize(void) const;//получить общий размер буфера 54 | void Reset(void);//удалить данные из буфера 55 | uint8_t GetByte(uint32_t pos) const;//получить значение из буфера 56 | void SetTailPos(uint32_t pos);//задать позицию хвоста буфера 57 | void SetHeadPos(uint32_t pos);//задать позицию головы буфера 58 | private: 59 | //-закрытые функции----------------------------------------------------------------------------------- 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /FlirOneControl/cgraphics.h: -------------------------------------------------------------------------------- 1 | #ifndef C_GRAPHICS_H 2 | #define C_GRAPHICS_H 3 | 4 | //**************************************************************************************************** 5 | //Класс рисования в буфере изображения 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include 12 | 13 | //**************************************************************************************************** 14 | //макроопределения 15 | //**************************************************************************************************** 16 | 17 | //**************************************************************************************************** 18 | //константы 19 | //**************************************************************************************************** 20 | 21 | //**************************************************************************************************** 22 | //предварительные объявления 23 | //**************************************************************************************************** 24 | 25 | //**************************************************************************************************** 26 | //Класс рисования в буфере изображения 27 | //**************************************************************************************************** 28 | class CGraphics 29 | { 30 | public: 31 | //-перечисления--------------------------------------------------------------------------------------- 32 | //-структуры------------------------------------------------------------------------------------------ 33 | //-константы------------------------------------------------------------------------------------------ 34 | static const int32_t FONT_WIDTH=8; 35 | static const int32_t FONT_HEIGHT=14; 36 | private: 37 | //-переменные----------------------------------------------------------------------------------------- 38 | uint32_t *VideoPtr;//указатель на видеобуфер (RGBA) 39 | int32_t ScreenWidth;//ширина изображения 40 | int32_t ScreenHeight;//высота изображения 41 | int32_t LineSize;//расмер строки изображения 42 | public: 43 | //-конструктор---------------------------------------------------------------------------------------- 44 | CGraphics(void); 45 | //-деструктор----------------------------------------------------------------------------------------- 46 | ~CGraphics(); 47 | public: 48 | //-открытые функции----------------------------------------------------------------------------------- 49 | void Init(uint32_t *video_ptr,int32_t screen_width,int32_t screen_height);//инициализация 50 | void PutSymbol(int32_t x,int32_t y,char symbol,uint32_t color);//вывод символа в позицию 51 | void PutString(int32_t x,int32_t y,const char *string,uint32_t color);//вывод строчки в позицию 52 | void SolidFill(int32_t x,int32_t y,int32_t width,int32_t height,uint32_t color);//закрасить прямоугольник 53 | void PutSymbolInversion(int32_t x,int32_t y,char symbol);//вывод символа в позицию с инверсией цвета 54 | void PutStringInversion(int32_t x,int32_t y,const char *string);//вывод строчки в позицию с инверсией цвета 55 | void DrawPointInversion(int32_t x,int32_t y);//поставить точку в позицию с инверсией цвета 56 | private: 57 | //-закрытые функции----------------------------------------------------------------------------------- 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/jcomapi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jcomapi.c 3 | * 4 | * Copyright (C) 1994-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains application interface routines that are used for both 9 | * compression and decompression. 10 | */ 11 | 12 | #define JPEG_INTERNALS 13 | #include "jinclude.h" 14 | #include "jpeglib.h" 15 | 16 | 17 | /* 18 | * Abort processing of a JPEG compression or decompression operation, 19 | * but don't destroy the object itself. 20 | * 21 | * For this, we merely clean up all the nonpermanent memory pools. 22 | * Note that temp files (virtual arrays) are not allowed to belong to 23 | * the permanent pool, so we will be able to close all temp files here. 24 | * Closing a data source or destination, if necessary, is the application's 25 | * responsibility. 26 | */ 27 | 28 | GLOBAL(void) 29 | jpeg_abort (j_common_ptr cinfo) 30 | { 31 | int pool; 32 | 33 | /* Do nothing if called on a not-initialized or destroyed JPEG object. */ 34 | if (cinfo->mem == NULL) 35 | return; 36 | 37 | /* Releasing pools in reverse order might help avoid fragmentation 38 | * with some (brain-damaged) malloc libraries. 39 | */ 40 | for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { 41 | (*cinfo->mem->free_pool) (cinfo, pool); 42 | } 43 | 44 | /* Reset overall state for possible reuse of object */ 45 | if (cinfo->is_decompressor) { 46 | cinfo->global_state = DSTATE_START; 47 | /* Try to keep application from accessing now-deleted marker list. 48 | * A bit kludgy to do it here, but this is the most central place. 49 | */ 50 | ((j_decompress_ptr) cinfo)->marker_list = NULL; 51 | } else { 52 | cinfo->global_state = CSTATE_START; 53 | } 54 | } 55 | 56 | 57 | /* 58 | * Destruction of a JPEG object. 59 | * 60 | * Everything gets deallocated except the master jpeg_compress_struct itself 61 | * and the error manager struct. Both of these are supplied by the application 62 | * and must be freed, if necessary, by the application. (Often they are on 63 | * the stack and so don't need to be freed anyway.) 64 | * Closing a data source or destination, if necessary, is the application's 65 | * responsibility. 66 | */ 67 | 68 | GLOBAL(void) 69 | jpeg_destroy (j_common_ptr cinfo) 70 | { 71 | /* We need only tell the memory manager to release everything. */ 72 | /* NB: mem pointer is NULL if memory mgr failed to initialize. */ 73 | if (cinfo->mem != NULL) 74 | (*cinfo->mem->self_destruct) (cinfo); 75 | cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ 76 | cinfo->global_state = 0; /* mark it destroyed */ 77 | } 78 | 79 | 80 | /* 81 | * Convenience routines for allocating quantization and Huffman tables. 82 | * (Would jutils.c be a more reasonable place to put these?) 83 | */ 84 | 85 | GLOBAL(JQUANT_TBL *) 86 | jpeg_alloc_quant_table (j_common_ptr cinfo) 87 | { 88 | JQUANT_TBL *tbl; 89 | 90 | tbl = (JQUANT_TBL *) 91 | (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); 92 | tbl->sent_table = FALSE; /* make sure this is false in any new table */ 93 | return tbl; 94 | } 95 | 96 | 97 | GLOBAL(JHUFF_TBL *) 98 | jpeg_alloc_huff_table (j_common_ptr cinfo) 99 | { 100 | JHUFF_TBL *tbl; 101 | 102 | tbl = (JHUFF_TBL *) 103 | (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); 104 | tbl->sent_table = FALSE; /* make sure this is false in any new table */ 105 | return tbl; 106 | } 107 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/jinclude.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jinclude.h 3 | * 4 | * Copyright (C) 1991-1994, Thomas G. Lane. 5 | * Modified 2017 by Guido Vollbeding. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file exists to provide a single place to fix any problems with 10 | * including the wrong system include files. (Common problems are taken 11 | * care of by the standard jconfig symbols, but on really weird systems 12 | * you may have to edit this file.) 13 | * 14 | * NOTE: this file is NOT intended to be included by applications using the 15 | * JPEG library. Most applications need only include jpeglib.h. 16 | */ 17 | 18 | 19 | /* Include auto-config file to find out which system include files we need. */ 20 | 21 | #include "jconfig.h" /* auto configuration options */ 22 | #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ 23 | 24 | /* 25 | * We need the NULL macro and size_t typedef. 26 | * On an ANSI-conforming system it is sufficient to include . 27 | * Otherwise, we get them from or ; we may have to 28 | * pull in as well. 29 | * Note that the core JPEG library does not require ; 30 | * only the default error handler and data source/destination modules do. 31 | * But we must pull it in because of the references to FILE in jpeglib.h. 32 | * You can remove those references if you want to compile without . 33 | */ 34 | 35 | #ifdef HAVE_STDDEF_H 36 | #include 37 | #endif 38 | 39 | #ifdef HAVE_STDLIB_H 40 | #include 41 | #endif 42 | 43 | #ifdef NEED_SYS_TYPES_H 44 | #include 45 | #endif 46 | 47 | #include 48 | 49 | /* 50 | * We need memory copying and zeroing functions, plus strncpy(). 51 | * ANSI and System V implementations declare these in . 52 | * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). 53 | * Some systems may declare memset and memcpy in . 54 | * 55 | * NOTE: we assume the size parameters to these functions are of type size_t. 56 | * Change the casts in these macros if not! 57 | */ 58 | 59 | #ifdef NEED_BSD_STRINGS 60 | 61 | #include 62 | #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) 63 | #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) 64 | 65 | #else /* not BSD, assume ANSI/SysV string lib */ 66 | 67 | #include 68 | #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) 69 | #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) 70 | 71 | #endif 72 | 73 | /* 74 | * In ANSI C, and indeed any rational implementation, size_t is also the 75 | * type returned by sizeof(). However, it seems there are some irrational 76 | * implementations out there, in which sizeof() returns an int even though 77 | * size_t is defined as long or unsigned long. To ensure consistent results 78 | * we always use this SIZEOF() macro in place of using sizeof() directly. 79 | */ 80 | 81 | #define SIZEOF(object) ((size_t) sizeof(object)) 82 | 83 | /* 84 | * The modules that use fread() and fwrite() always invoke them through 85 | * these macros. On some systems you may need to twiddle the argument casts. 86 | * CAUTION: argument order is different from underlying functions! 87 | * 88 | * Furthermore, macros are provided for fflush() and ferror() in order 89 | * to facilitate adaption by applications using an own FILE class. 90 | */ 91 | 92 | #define JFREAD(file,buf,sizeofbuf) \ 93 | ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 94 | #define JFWRITE(file,buf,sizeofbuf) \ 95 | ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 96 | #define JFFLUSH(file) fflush(file) 97 | #define JFERROR(file) ferror(file) 98 | -------------------------------------------------------------------------------- /FlirOneControl/clanguage.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "clanguage.h" 5 | #include "clanguagerussian.h" 6 | #include "clanguageenglish.h" 7 | 8 | //**************************************************************************************************** 9 | //глобальные переменные 10 | //**************************************************************************************************** 11 | 12 | std::unique_ptr CLanguage::cLanguage_Ptr; 13 | std::unique_ptr CLanguage::iLanguage_Ptr; 14 | 15 | //**************************************************************************************************** 16 | //константы 17 | //**************************************************************************************************** 18 | 19 | //**************************************************************************************************** 20 | //макроопределения 21 | //**************************************************************************************************** 22 | 23 | //**************************************************************************************************** 24 | //конструктор и деструктор 25 | //**************************************************************************************************** 26 | 27 | //---------------------------------------------------------------------------------------------------- 28 | //конструктор 29 | //---------------------------------------------------------------------------------------------------- 30 | CLanguage::CLanguage(void) 31 | { 32 | SelectedLanguage=LANGUAGE_ENGLISH; 33 | } 34 | //---------------------------------------------------------------------------------------------------- 35 | //деструктор 36 | //---------------------------------------------------------------------------------------------------- 37 | CLanguage::~CLanguage() 38 | { 39 | } 40 | 41 | //**************************************************************************************************** 42 | //закрытые функции 43 | //**************************************************************************************************** 44 | 45 | //**************************************************************************************************** 46 | //открытые функции 47 | //**************************************************************************************************** 48 | 49 | //---------------------------------------------------------------------------------------------------- 50 | //получить указатель на класс сообщений 51 | //---------------------------------------------------------------------------------------------------- 52 | CLanguage* CLanguage::GetPtr(void) 53 | { 54 | if (cLanguage_Ptr.get()==NULL) cLanguage_Ptr.reset(new CLanguage()); 55 | return(cLanguage_Ptr.get()); 56 | } 57 | //---------------------------------------------------------------------------------------------------- 58 | //получить указатель на класс сообщений на выбранном языке 59 | //---------------------------------------------------------------------------------------------------- 60 | ILanguage* CLanguage::GetTextPtr(void) 61 | { 62 | if (iLanguage_Ptr.get()==NULL) SetLanguage(SelectedLanguage); 63 | return(iLanguage_Ptr.get()); 64 | } 65 | //---------------------------------------------------------------------------------------------------- 66 | //задать язык 67 | //---------------------------------------------------------------------------------------------------- 68 | void CLanguage::SetLanguage(LANGUAGE language) 69 | { 70 | SelectedLanguage=language; 71 | if (SelectedLanguage==LANGUAGE_RUSSIAN) iLanguage_Ptr.reset(new CLanguageRussian()); 72 | if (SelectedLanguage==LANGUAGE_ENGLISH) iLanguage_Ptr.reset(new CLanguageEnglish()); 73 | } 74 | -------------------------------------------------------------------------------- /FlirOneControl/clog.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "clog.h" 5 | 6 | //**************************************************************************************************** 7 | //глобальные переменные 8 | //**************************************************************************************************** 9 | 10 | std::unique_ptr CLog::cLog_Ptr; 11 | 12 | //**************************************************************************************************** 13 | //константы 14 | //**************************************************************************************************** 15 | 16 | //**************************************************************************************************** 17 | //макроопределения 18 | //**************************************************************************************************** 19 | 20 | //**************************************************************************************************** 21 | //конструктор и деструктор 22 | //**************************************************************************************************** 23 | 24 | //---------------------------------------------------------------------------------------------------- 25 | //конструктор 26 | //---------------------------------------------------------------------------------------------------- 27 | CLog::CLog(void) 28 | { 29 | } 30 | //---------------------------------------------------------------------------------------------------- 31 | //деструктор 32 | //---------------------------------------------------------------------------------------------------- 33 | CLog::~CLog() 34 | { 35 | } 36 | 37 | //**************************************************************************************************** 38 | //закрытые функции 39 | //**************************************************************************************************** 40 | 41 | //---------------------------------------------------------------------------------------------------- 42 | // 43 | //---------------------------------------------------------------------------------------------------- 44 | 45 | //**************************************************************************************************** 46 | //статические открытые функции 47 | //**************************************************************************************************** 48 | 49 | //---------------------------------------------------------------------------------------------------- 50 | //получить указатель на класс вывода работы программы 51 | //---------------------------------------------------------------------------------------------------- 52 | CLog* CLog::GetPtr(void) 53 | { 54 | if (cLog_Ptr.get()==NULL) cLog_Ptr.reset(new CLog()); 55 | return(cLog_Ptr.get()); 56 | } 57 | 58 | //**************************************************************************************************** 59 | //открытые функции 60 | //**************************************************************************************************** 61 | 62 | //---------------------------------------------------------------------------------------------------- 63 | //добавить строку в log-файл 64 | //---------------------------------------------------------------------------------------------------- 65 | void CLog::AddLog(const std::string &string) 66 | { 67 | return; 68 | FILE *file=fopen("log.txt","ab"); 69 | if (file==NULL) return; 70 | fprintf(file,"%s",string.c_str()); 71 | fclose(file); 72 | } 73 | //---------------------------------------------------------------------------------------------------- 74 | //добавить число в log-файл 75 | //---------------------------------------------------------------------------------------------------- 76 | void CLog::AddLog(int32_t value) 77 | { 78 | return; 79 | FILE *file=fopen("log.txt","ab"); 80 | if (file==NULL) return; 81 | fprintf(file,"%i",value); 82 | fclose(file); 83 | } 84 | 85 | -------------------------------------------------------------------------------- /FlirOneControl/clabel_imagearea.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "clabel_imagearea.h" 5 | #include 6 | 7 | //**************************************************************************************************** 8 | //глобальные переменные 9 | //**************************************************************************************************** 10 | 11 | //**************************************************************************************************** 12 | //константы 13 | //**************************************************************************************************** 14 | 15 | //**************************************************************************************************** 16 | //макроопределения 17 | //**************************************************************************************************** 18 | 19 | //**************************************************************************************************** 20 | //конструктор и деструктор 21 | //**************************************************************************************************** 22 | 23 | //---------------------------------------------------------------------------------------------------- 24 | //конструктор 25 | //---------------------------------------------------------------------------------------------------- 26 | CLabel_ImageArea::CLabel_ImageArea(uint32_t width,uint32_t height,QWidget *parent):QLabel(parent) 27 | { 28 | qImage=QImage(width,height,QImage::Format_RGBA8888); 29 | for(size_t y=0;ywidth(),parentWidget()->height()); 53 | setMaximumSize(parentWidget()->width(),parentWidget()->height()); 54 | setMinimumSize(parentWidget()->width(),parentWidget()->height()); 55 | 56 | QLabel::paintEvent(qPaintEvent_Ptr); 57 | QPixmap qPixmap=QPixmap::fromImage(qImage); 58 | // setPixmap(qPixmap.scaled(this->width(),this->height(),Qt::KeepAspectRatio)); 59 | setPixmap(qPixmap.scaled(this->width(),this->height())); 60 | 61 | } 62 | //**************************************************************************************************** 63 | //открытые функции 64 | //**************************************************************************************************** 65 | 66 | //---------------------------------------------------------------------------------------------------- 67 | //заменить изображение 68 | //---------------------------------------------------------------------------------------------------- 69 | void CLabel_ImageArea::Redraw(const uint32_t *image_data) 70 | { 71 | const uint32_t *vptr=image_data; 72 | uint32_t linesize=qImage.width(); 73 | //делаем перекодирование цветов для вывода на экран 74 | for(int32_t y=0;y>0)&0xff; 81 | uint8_t g=(color>>8)&0xff; 82 | uint8_t r=(color>>16)&0xff; 83 | qImage.setPixel(x,y,qRgb(r,g,b)); 84 | } 85 | } 86 | update(); 87 | } 88 | -------------------------------------------------------------------------------- /FlirOneControl/clanguageenglish.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "clanguageenglish.h" 5 | 6 | //**************************************************************************************************** 7 | //глобальные переменные 8 | //**************************************************************************************************** 9 | 10 | //**************************************************************************************************** 11 | //константы 12 | //**************************************************************************************************** 13 | 14 | //**************************************************************************************************** 15 | //макроопределения 16 | //**************************************************************************************************** 17 | 18 | //**************************************************************************************************** 19 | //конструктор и деструктор 20 | //**************************************************************************************************** 21 | 22 | //---------------------------------------------------------------------------------------------------- 23 | //конструктор 24 | //---------------------------------------------------------------------------------------------------- 25 | CLanguageEnglish::CLanguageEnglish(void) 26 | { 27 | } 28 | //---------------------------------------------------------------------------------------------------- 29 | //деструктор 30 | //---------------------------------------------------------------------------------------------------- 31 | CLanguageEnglish::~CLanguageEnglish() 32 | { 33 | } 34 | 35 | //**************************************************************************************************** 36 | //закрытые функции 37 | //**************************************************************************************************** 38 | 39 | //**************************************************************************************************** 40 | //открытые функции 41 | //**************************************************************************************************** 42 | 43 | std::string CLanguageEnglish::WindowTitle(void) 44 | { 45 | return("Flir One control programm"); 46 | } 47 | std::string CLanguageEnglish::Label_Emission(void) 48 | { 49 | return("Emission"); 50 | } 51 | std::string CLanguageEnglish::Label_Temper(void) 52 | { 53 | return("Bolometer temperature"); 54 | } 55 | std::string CLanguageEnglish::Label_Palette(void) 56 | { 57 | return("Palette"); 58 | } 59 | std::string CLanguageEnglish::Label_Alarm(void) 60 | { 61 | return("If the temperature is out of range do:"); 62 | } 63 | std::string CLanguageEnglish::Button_ApplyPalette(void) 64 | { 65 | return("Apply palette"); 66 | } 67 | std::string CLanguageEnglish::Button_ShowVideo(void) 68 | { 69 | return("Show video"); 70 | } 71 | std::string CLanguageEnglish::Button_SaveImageCross(void) 72 | { 73 | return("Save image with cross"); 74 | } 75 | std::string CLanguageEnglish::Button_SaveImageNoScale(void) 76 | { 77 | return("Save image without scale"); 78 | } 79 | std::string CLanguageEnglish::Button_SaveRAW(void) 80 | { 81 | return("Save RAW file"); 82 | } 83 | std::string CLanguageEnglish::Button_SaveVideo(void) 84 | { 85 | return("Save video frame"); 86 | } 87 | std::string CLanguageEnglish::Button_SaveAllFrame(void) 88 | { 89 | return("Save all frame"); 90 | } 91 | std::string CLanguageEnglish::Button_SaveFrame(void) 92 | { 93 | return("Save one frame"); 94 | } 95 | std::string CLanguageEnglish::Label_LevelMinT(void) 96 | { 97 | return("Alarm level min temperature"); 98 | } 99 | std::string CLanguageEnglish::Label_LevelMaxT(void) 100 | { 101 | return("Alarm level max temperature"); 102 | } 103 | std::string CLanguageEnglish::CheckBox_SaveFrame(void) 104 | { 105 | return("Save frame"); 106 | } 107 | 108 | -------------------------------------------------------------------------------- /FlirOneControl/clanguagerussian.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "clanguagerussian.h" 5 | 6 | //**************************************************************************************************** 7 | //глобальные переменные 8 | //**************************************************************************************************** 9 | 10 | //**************************************************************************************************** 11 | //константы 12 | //**************************************************************************************************** 13 | 14 | //**************************************************************************************************** 15 | //макроопределения 16 | //**************************************************************************************************** 17 | 18 | //**************************************************************************************************** 19 | //конструктор и деструктор 20 | //**************************************************************************************************** 21 | 22 | //---------------------------------------------------------------------------------------------------- 23 | //конструктор 24 | //---------------------------------------------------------------------------------------------------- 25 | CLanguageRussian::CLanguageRussian(void) 26 | { 27 | } 28 | //---------------------------------------------------------------------------------------------------- 29 | //деструктор 30 | //---------------------------------------------------------------------------------------------------- 31 | CLanguageRussian::~CLanguageRussian() 32 | { 33 | } 34 | 35 | //**************************************************************************************************** 36 | //закрытые функции 37 | //**************************************************************************************************** 38 | 39 | 40 | //**************************************************************************************************** 41 | //открытые функции 42 | //**************************************************************************************************** 43 | 44 | std::string CLanguageRussian::WindowTitle(void) 45 | { 46 | return("Управление тепловизором Flir One"); 47 | } 48 | std::string CLanguageRussian::Label_Emission(void) 49 | { 50 | return("Коэффициент излучения материала"); 51 | } 52 | std::string CLanguageRussian::Label_Temper(void) 53 | { 54 | return("Температура болометров"); 55 | } 56 | std::string CLanguageRussian::Label_Palette(void) 57 | { 58 | return("Палитра"); 59 | } 60 | std::string CLanguageRussian::Label_Alarm(void) 61 | { 62 | return("При выходе за границы температуры выполнить:"); 63 | } 64 | std::string CLanguageRussian::Button_ApplyPalette(void) 65 | { 66 | return("Применить палитру"); 67 | } 68 | std::string CLanguageRussian::Button_ShowVideo(void) 69 | { 70 | return("Показывать видео"); 71 | } 72 | std::string CLanguageRussian::Button_SaveImageCross(void) 73 | { 74 | return("Сохранять кадры с перекрестьем"); 75 | } 76 | std::string CLanguageRussian::Button_SaveImageNoScale(void) 77 | { 78 | return("Сохранять изображения без шкалы"); 79 | } 80 | std::string CLanguageRussian::Button_SaveRAW(void) 81 | { 82 | return("Сохранять файл RAW"); 83 | } 84 | std::string CLanguageRussian::Button_SaveVideo(void) 85 | { 86 | return("Сохранять кадры с видеокамеры"); 87 | } 88 | std::string CLanguageRussian::Button_SaveAllFrame(void) 89 | { 90 | return("Сохранять все кадры"); 91 | } 92 | std::string CLanguageRussian::Button_SaveFrame(void) 93 | { 94 | return("Сохранить один кадр"); 95 | } 96 | std::string CLanguageRussian::Label_LevelMinT(void) 97 | { 98 | return("Нижняя граница температуры для сигнализации"); 99 | } 100 | std::string CLanguageRussian::Label_LevelMaxT(void) 101 | { 102 | return("Верхняя граница температуры для сигнализации"); 103 | } 104 | std::string CLanguageRussian::CheckBox_SaveFrame(void) 105 | { 106 | return("Сохранить кадр"); 107 | } 108 | 109 | -------------------------------------------------------------------------------- /FlirOneControl/cdecorator_iimage.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "cdecorator_iimage.h" 5 | 6 | //**************************************************************************************************** 7 | //глобальные переменные 8 | //**************************************************************************************************** 9 | 10 | //**************************************************************************************************** 11 | //константы 12 | //**************************************************************************************************** 13 | 14 | //**************************************************************************************************** 15 | //макроопределения 16 | //**************************************************************************************************** 17 | 18 | //**************************************************************************************************** 19 | //конструктор и деструктор 20 | //**************************************************************************************************** 21 | 22 | //---------------------------------------------------------------------------------------------------- 23 | //конструктор 24 | //---------------------------------------------------------------------------------------------------- 25 | CDecorator_IImage::CDecorator_IImage(IImage *iImage_Set_Ptr) 26 | { 27 | iImage_Ptr=iImage_Set_Ptr; 28 | } 29 | //---------------------------------------------------------------------------------------------------- 30 | //деструктор 31 | //---------------------------------------------------------------------------------------------------- 32 | CDecorator_IImage::~CDecorator_IImage() 33 | { 34 | delete(iImage_Ptr); 35 | } 36 | 37 | //**************************************************************************************************** 38 | //закрытые функции 39 | //**************************************************************************************************** 40 | 41 | //**************************************************************************************************** 42 | //открытые функции 43 | //**************************************************************************************************** 44 | 45 | //---------------------------------------------------------------------------------------------------- 46 | //получить RGBA изображение 47 | //---------------------------------------------------------------------------------------------------- 48 | void CDecorator_IImage::GetRGBAImage(uint32_t &width,uint32_t &height,std::vector &vector_image) 49 | { 50 | iImage_Ptr->GetRGBAImage(width,height,vector_image); 51 | } 52 | //---------------------------------------------------------------------------------------------------- 53 | //задать RGBA изображение 54 | //---------------------------------------------------------------------------------------------------- 55 | void CDecorator_IImage::SetRGBAImage(const uint32_t &width,const uint32_t &height,const std::vector &vector_image) 56 | { 57 | iImage_Ptr->SetRGBAImage(width,height,vector_image); 58 | } 59 | //---------------------------------------------------------------------------------------------------- 60 | //задать размер изображения и выделить память 61 | //---------------------------------------------------------------------------------------------------- 62 | void CDecorator_IImage::SetSize(uint32_t width,uint32_t height) 63 | { 64 | iImage_Ptr->SetSize(width,height); 65 | } 66 | //---------------------------------------------------------------------------------------------------- 67 | //задать точку 68 | //---------------------------------------------------------------------------------------------------- 69 | void CDecorator_IImage::SetRGBAPixel(uint32_t x,uint32_t y,uint32_t color) 70 | { 71 | iImage_Ptr->SetRGBAPixel(x,y,color); 72 | } 73 | //---------------------------------------------------------------------------------------------------- 74 | //получить точку 75 | //---------------------------------------------------------------------------------------------------- 76 | uint32_t CDecorator_IImage::GetRGBAPixel(uint32_t x,uint32_t y) 77 | { 78 | return(iImage_Ptr->GetRGBAPixel(x,y)); 79 | } 80 | -------------------------------------------------------------------------------- /FlirOneControl/cpicture.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "cpicture.h" 5 | 6 | //**************************************************************************************************** 7 | //глобальные переменные 8 | //**************************************************************************************************** 9 | 10 | //**************************************************************************************************** 11 | //константы 12 | //**************************************************************************************************** 13 | 14 | //**************************************************************************************************** 15 | //макроопределения 16 | //**************************************************************************************************** 17 | 18 | //**************************************************************************************************** 19 | //конструктор и деструктор 20 | //**************************************************************************************************** 21 | 22 | //---------------------------------------------------------------------------------------------------- 23 | //конструктор 24 | //---------------------------------------------------------------------------------------------------- 25 | CPicture::CPicture(void) 26 | { 27 | Width=0; 28 | Height=0; 29 | } 30 | //---------------------------------------------------------------------------------------------------- 31 | //деструктор 32 | //---------------------------------------------------------------------------------------------------- 33 | CPicture::~CPicture() 34 | { 35 | } 36 | 37 | //**************************************************************************************************** 38 | //закрытые функции 39 | //**************************************************************************************************** 40 | 41 | //**************************************************************************************************** 42 | //открытые функции 43 | //**************************************************************************************************** 44 | 45 | //---------------------------------------------------------------------------------------------------- 46 | //получить изображение в формате RGBA 47 | //---------------------------------------------------------------------------------------------------- 48 | void CPicture::GetRGBAImage(uint32_t &width,uint32_t &height,std::vector &vector_image) 49 | { 50 | width=Width; 51 | height=Height; 52 | vector_image=vector_Image; 53 | } 54 | //---------------------------------------------------------------------------------------------------- 55 | //задать изображение в формате RGBA 56 | //---------------------------------------------------------------------------------------------------- 57 | void CPicture::SetRGBAImage(const uint32_t &width,const uint32_t &height,const std::vector &vector_image) 58 | { 59 | Width=width; 60 | Height=height; 61 | vector_Image=vector_image; 62 | } 63 | //---------------------------------------------------------------------------------------------------- 64 | //задать размер изображения и выделить память 65 | //---------------------------------------------------------------------------------------------------- 66 | void CPicture::SetSize(uint32_t width,uint32_t height) 67 | { 68 | Width=width; 69 | Height=height; 70 | vector_Image.resize(Width*Height); 71 | } 72 | //---------------------------------------------------------------------------------------------------- 73 | //задать точку 74 | //---------------------------------------------------------------------------------------------------- 75 | void CPicture::SetRGBAPixel(uint32_t x,uint32_t y,uint32_t color) 76 | { 77 | if (x>=Width) return; 78 | if (y>=Height) return; 79 | vector_Image[x+y*Width]=color; 80 | } 81 | //---------------------------------------------------------------------------------------------------- 82 | //получить точку 83 | //---------------------------------------------------------------------------------------------------- 84 | uint32_t CPicture::GetRGBAPixel(uint32_t x,uint32_t y) 85 | { 86 | if (x>=Width) return(0); 87 | if (y>=Height) return(0); 88 | return(vector_Image[x+y*Width]); 89 | } 90 | -------------------------------------------------------------------------------- /FlirOneControl/FlirOneControl.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2020-05-18T19:11:28 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = FlirOneControl 12 | TEMPLATE = app 13 | LIBS +=-L/usr/local/lib -lusb-1.0 14 | 15 | 16 | # The following define makes your compiler emit warnings if you use 17 | # any feature of Qt which has been marked as deprecated (the exact warnings 18 | # depend on your compiler). Please consult the documentation of the 19 | # deprecated API in order to know how to port your code away from it. 20 | DEFINES += QT_DEPRECATED_WARNINGS 21 | 22 | # You can also make your code fail to compile if you use deprecated APIs. 23 | # In order to do so, uncomment the following line. 24 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 25 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 26 | 27 | 28 | SOURCES += \ 29 | cflironecontrol.cpp \ 30 | cmainwindow.cpp \ 31 | cringbuffer.cpp \ 32 | main.cpp \ 33 | cflironereceiver.cpp \ 34 | cmutex.cpp \ 35 | cthread.cpp \ 36 | system.cpp \ 37 | tga.cpp \ 38 | cflironedriver.cpp \ 39 | craiifileout.cpp \ 40 | craiifilein.cpp \ 41 | clog.cpp \ 42 | cdecorator_iimage.cpp \ 43 | cdecorator_scale.cpp \ 44 | cpicture.cpp \ 45 | iimage.cpp \ 46 | cgraphics.cpp \ 47 | clabel_imagearea.cpp \ 48 | libjpeg/cdjpeg.c \ 49 | libjpeg/jaricom.c \ 50 | libjpeg/jcapimin.c \ 51 | libjpeg/jcapistd.c \ 52 | libjpeg/jcarith.c \ 53 | libjpeg/jccoefct.c \ 54 | libjpeg/jccolor.c \ 55 | libjpeg/jcdctmgr.c \ 56 | libjpeg/jchuff.c \ 57 | libjpeg/jcinit.c \ 58 | libjpeg/jcmainct.c \ 59 | libjpeg/jcmarker.c \ 60 | libjpeg/jcmaster.c \ 61 | libjpeg/jcomapi.c \ 62 | libjpeg/jcparam.c \ 63 | libjpeg/jcprepct.c \ 64 | libjpeg/jcsample.c \ 65 | libjpeg/jctrans.c \ 66 | libjpeg/jdapimin.c \ 67 | libjpeg/jdapistd.c \ 68 | libjpeg/jdarith.c \ 69 | libjpeg/jdatadst.c \ 70 | libjpeg/jdatasrc.c \ 71 | libjpeg/jdcoefct.c \ 72 | libjpeg/jdcolor.c \ 73 | libjpeg/jddctmgr.c \ 74 | libjpeg/jdhuff.c \ 75 | libjpeg/jdinput.c \ 76 | libjpeg/jdmainct.c \ 77 | libjpeg/jdmarker.c \ 78 | libjpeg/jdmaster.c \ 79 | libjpeg/jdmerge.c \ 80 | libjpeg/jdpostct.c \ 81 | libjpeg/jdsample.c \ 82 | libjpeg/jdtrans.c \ 83 | libjpeg/jerror.c \ 84 | libjpeg/jfdctflt.c \ 85 | libjpeg/jfdctfst.c \ 86 | libjpeg/jfdctint.c \ 87 | libjpeg/jidctflt.c \ 88 | libjpeg/jidctfst.c \ 89 | libjpeg/jidctint.c \ 90 | libjpeg/jmemansi.c \ 91 | libjpeg/jmemmgr.c \ 92 | libjpeg/jquant1.c \ 93 | libjpeg/jquant2.c \ 94 | libjpeg/jutils.c \ 95 | libjpeg/rdbmp.c \ 96 | libjpeg/rdcolmap.c \ 97 | libjpeg/rdgif.c \ 98 | libjpeg/rdppm.c \ 99 | libjpeg/rdrle.c \ 100 | libjpeg/rdswitch.c \ 101 | libjpeg/rdtarga.c \ 102 | libjpeg/transupp.c \ 103 | libjpeg/wrbmp.c \ 104 | libjpeg/wrgif.c \ 105 | libjpeg/wrppm.c \ 106 | libjpeg/wrrle.c \ 107 | libjpeg/wrtarga.c \ 108 | clanguage.cpp \ 109 | ilanguage.cpp \ 110 | clanguageenglish.cpp \ 111 | clanguagerussian.cpp 112 | 113 | HEADERS += \ 114 | cflironecontrol.h \ 115 | cmainwindow.h \ 116 | cringbuffer.h \ 117 | cflironereceiver.h \ 118 | cmutex.h \ 119 | craiicmutex.h \ 120 | cthread.h \ 121 | system.h \ 122 | tga.h \ 123 | cflironedriver.h \ 124 | craiifileout.h \ 125 | craiifilein.h \ 126 | libusb.h \ 127 | clog.h \ 128 | cdecorator_iimage.h \ 129 | cdecorator_scale.h \ 130 | cpicture.h \ 131 | iimage.h \ 132 | cgraphics.h \ 133 | clabel_imagearea.h \ 134 | libjpeg/cderror.h \ 135 | libjpeg/cdjpeg.h \ 136 | libjpeg/jconfig.h \ 137 | libjpeg/jdct.h \ 138 | libjpeg/jerror.h \ 139 | libjpeg/jinclude.h \ 140 | libjpeg/jmemsys.h \ 141 | libjpeg/jmorecfg.h \ 142 | libjpeg/jpegint.h \ 143 | libjpeg/jpeglib.h \ 144 | libjpeg/jversion.h \ 145 | libjpeg/transupp.h \ 146 | clanguage.h \ 147 | ilanguage.h \ 148 | clanguageenglish.h \ 149 | clanguagerussian.h 150 | 151 | FORMS += \ 152 | cmainwindow.ui 153 | -------------------------------------------------------------------------------- /FlirOneControl/cflironecontrol.h: -------------------------------------------------------------------------------- 1 | #ifndef C_FLIR_ONE_CONTROL_H 2 | #define C_FLIR_ONE_CONTROL_H 3 | 4 | //**************************************************************************************************** 5 | //Класс управления Flir One 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "cthread.h" 17 | #include "cmutex.h" 18 | #include "cflironereceiver.h" 19 | #include "cflironedriver.h" 20 | 21 | //**************************************************************************************************** 22 | //макроопределения 23 | //**************************************************************************************************** 24 | 25 | //бесконечное малое 26 | #define EPS 0.00000001 27 | 28 | //**************************************************************************************************** 29 | //константы 30 | //**************************************************************************************************** 31 | 32 | //**************************************************************************************************** 33 | //предварительные объявления 34 | //**************************************************************************************************** 35 | 36 | //**************************************************************************************************** 37 | //Класс управления Flir One 38 | //**************************************************************************************************** 39 | class CFlirOneControl 40 | { 41 | friend void* ThreadFunction(void *ptr);//поток обработки 42 | public: 43 | //-перечисления--------------------------------------------------------------------------------------- 44 | //-структуры------------------------------------------------------------------------------------------ 45 | //-константы------------------------------------------------------------------------------------------ 46 | static const size_t RECEIVE_BUFFER_SIZE=1048576;//размер буфера приёма данных 47 | private: 48 | //-переменные----------------------------------------------------------------------------------------- 49 | struct SProtected 50 | { 51 | CMutex cMutex;//мютекс для доступа к данным 52 | bool ExitThread;//необходимость завершения потока 53 | CFlirOneReceiver cFlirOneReceiver;//класс приёма данных от Flir One 54 | } sProtected;//защищённые переменные 55 | CFlirOneDriver cFlirOneDriver;//класс драйверов для Flir One 56 | CThread cThread_Processing;//поток обработки 57 | int32_t Delay;//пауза для работы потока 58 | std::unique_ptr ReceiveBuffer_Ptr;//указатель на буфер приёма данных 59 | public: 60 | //-конструктор---------------------------------------------------------------------------------------- 61 | CFlirOneControl(void); 62 | //-деструктор----------------------------------------------------------------------------------------- 63 | ~CFlirOneControl(); 64 | public: 65 | //-открытые функции----------------------------------------------------------------------------------- 66 | bool Open(void);//подключиться к устройству 67 | void Close(void);//отключиться от устройства 68 | bool LoadColorMap(const std::string &filename);//загрузить карту перекодировки изображения 69 | bool CopyColorImage(std::vector &image,uint32_t &index);//скопировать раскрашенное изображение в буфер 70 | bool CopyThermalImage(std::vector &image,uint32_t &index);//скопировать тепловое изображение в буфер 71 | bool CopyVideoImage(std::vector &image,uint32_t &index);//скопировать изображение с видеокамеры в буфер 72 | bool CopyColorMap(uint8_t R[CFlirOneReceiver::COLOR_MAP_UNIT],uint8_t G[CFlirOneReceiver::COLOR_MAP_UNIT],uint8_t B[CFlirOneReceiver::COLOR_MAP_UNIT],uint32_t size);//скопировать палитру 73 | void SetShowVideo(bool state);//показывать ли видео 74 | private: 75 | //-закрытые функции----------------------------------------------------------------------------------- 76 | bool Processing(void);//обработка (вызывается только потоком) 77 | void StartThread(void);//запустить поток 78 | void StopThread(void);//остановить поток 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/jmemansi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jmemansi.c 3 | * 4 | * Copyright (C) 1992-1996, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of dstribution and use, see the accompanying README file. 7 | * 8 | * This file provides a simple generic implementation of the system- 9 | * dependent portion of the JPEG memory manager. This implementation 10 | * assumes that you have the ANSI-standard library routine tmpfile(). 11 | * Also, the problem of determining the amount of memory available 12 | * is shoved onto the user. 13 | */ 14 | 15 | #define JPEG_INTERNALS 16 | #include "jinclude.h" 17 | #include "jpeglib.h" 18 | #include "jmemsys.h" /* import the system-dependent declarations */ 19 | 20 | #ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ 21 | extern void * malloc JPP((size_t size)); 22 | extern void free JPP((void *ptr)); 23 | #endif 24 | 25 | #ifndef SEEK_SET /* pre-ANSI systems may not define this; */ 26 | #define SEEK_SET 0 /* if not, assume 0 is correct */ 27 | #endif 28 | 29 | 30 | /* 31 | * Memory allocation and freeing are controlled by the regular library 32 | * routines malloc() and free(). 33 | */ 34 | 35 | GLOBAL(void *) 36 | jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) 37 | { 38 | return (void *) malloc(sizeofobject); 39 | } 40 | 41 | GLOBAL(void) 42 | jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) 43 | { 44 | free(object); 45 | } 46 | 47 | 48 | /* 49 | * "Large" objects are treated the same as "small" ones. 50 | * NB: although we include FAR keywords in the routine declarations, 51 | * this file won't actually work in 80x86 small/medium model; at least, 52 | * you probably won't be able to process useful-size images in only 64KB. 53 | */ 54 | 55 | GLOBAL(void FAR *) 56 | jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) 57 | { 58 | return (void FAR *) malloc(sizeofobject); 59 | } 60 | 61 | GLOBAL(void) 62 | jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) 63 | { 64 | free(object); 65 | } 66 | 67 | 68 | /* 69 | * This routine computes the total memory space available for allocation. 70 | * It's impossible to do this in a portable way; our current solution is 71 | * to make the user tell us (with a default value set at compile time). 72 | * If you can actually get the available space, it's a good idea to subtract 73 | * a slop factor of 5% or so. 74 | */ 75 | 76 | #ifndef DEFAULT_MAX_MEM /* so can override from makefile */ 77 | #define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ 78 | #endif 79 | 80 | GLOBAL(long) 81 | jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, 82 | long max_bytes_needed, long already_allocated) 83 | { 84 | return cinfo->mem->max_memory_to_use - already_allocated; 85 | } 86 | 87 | 88 | /* 89 | * Backing store (temporary file) management. 90 | * Backing store objects are only used when the value returned by 91 | * jpeg_mem_available is less than the total space needed. You can dispense 92 | * with these routines if you have plenty of virtual memory; see jmemnobs.c. 93 | */ 94 | 95 | 96 | METHODDEF(void) 97 | read_backing_store (j_common_ptr cinfo, backing_store_ptr info, 98 | void FAR * buffer_address, 99 | long file_offset, long byte_count) 100 | { 101 | if (fseek(info->temp_file, file_offset, SEEK_SET)) 102 | ERREXIT(cinfo, JERR_TFILE_SEEK); 103 | if (JFREAD(info->temp_file, buffer_address, byte_count) 104 | != (size_t) byte_count) 105 | ERREXIT(cinfo, JERR_TFILE_READ); 106 | } 107 | 108 | 109 | METHODDEF(void) 110 | write_backing_store (j_common_ptr cinfo, backing_store_ptr info, 111 | void FAR * buffer_address, 112 | long file_offset, long byte_count) 113 | { 114 | if (fseek(info->temp_file, file_offset, SEEK_SET)) 115 | ERREXIT(cinfo, JERR_TFILE_SEEK); 116 | if (JFWRITE(info->temp_file, buffer_address, byte_count) 117 | != (size_t) byte_count) 118 | ERREXIT(cinfo, JERR_TFILE_WRITE); 119 | } 120 | 121 | 122 | METHODDEF(void) 123 | close_backing_store (j_common_ptr cinfo, backing_store_ptr info) 124 | { 125 | fclose(info->temp_file); 126 | /* Since this implementation uses tmpfile() to create the file, 127 | * no explicit file deletion is needed. 128 | */ 129 | } 130 | 131 | 132 | /* 133 | * Initial opening of a backing-store object. 134 | * 135 | * This version uses tmpfile(), which constructs a suitable file name 136 | * behind the scenes. We don't have to use info->temp_name[] at all; 137 | * indeed, we can't even find out the actual name of the temp file. 138 | */ 139 | 140 | GLOBAL(void) 141 | jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, 142 | long total_bytes_needed) 143 | { 144 | if ((info->temp_file = tmpfile()) == NULL) 145 | ERREXITS(cinfo, JERR_TFILE_CREATE, ""); 146 | info->read_backing_store = read_backing_store; 147 | info->write_backing_store = write_backing_store; 148 | info->close_backing_store = close_backing_store; 149 | } 150 | 151 | 152 | /* 153 | * These routines take care of any system-dependent initialization and 154 | * cleanup required. 155 | */ 156 | 157 | GLOBAL(long) 158 | jpeg_mem_init (j_common_ptr cinfo) 159 | { 160 | return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ 161 | } 162 | 163 | GLOBAL(void) 164 | jpeg_mem_term (j_common_ptr cinfo) 165 | { 166 | /* no work */ 167 | } 168 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/cdjpeg.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cdjpeg.c 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains common support routines used by the IJG application 9 | * programs (cjpeg, djpeg, jpegtran). 10 | */ 11 | 12 | #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ 13 | #include /* to declare isupper(), tolower() */ 14 | #ifdef NEED_SIGNAL_CATCHER 15 | #include /* to declare signal() */ 16 | #endif 17 | #ifdef USE_SETMODE 18 | #include /* to declare setmode()'s parameter macros */ 19 | /* If you have setmode() but not , just delete this line: */ 20 | #include /* to declare setmode() */ 21 | #endif 22 | 23 | 24 | /* 25 | * Signal catcher to ensure that temporary files are removed before aborting. 26 | * NB: for Amiga Manx C this is actually a global routine named _abort(); 27 | * we put "#define signal_catcher _abort" in jconfig.h. Talk about bogus... 28 | */ 29 | 30 | #ifdef NEED_SIGNAL_CATCHER 31 | 32 | static j_common_ptr sig_cinfo; 33 | 34 | void /* must be global for Manx C */ 35 | signal_catcher (int signum) 36 | { 37 | if (sig_cinfo != NULL) { 38 | if (sig_cinfo->err != NULL) /* turn off trace output */ 39 | sig_cinfo->err->trace_level = 0; 40 | jpeg_destroy(sig_cinfo); /* clean up memory allocation & temp files */ 41 | } 42 | exit(EXIT_FAILURE); 43 | } 44 | 45 | 46 | GLOBAL(void) 47 | enable_signal_catcher (j_common_ptr cinfo) 48 | { 49 | sig_cinfo = cinfo; 50 | #ifdef SIGINT /* not all systems have SIGINT */ 51 | signal(SIGINT, signal_catcher); 52 | #endif 53 | #ifdef SIGTERM /* not all systems have SIGTERM */ 54 | signal(SIGTERM, signal_catcher); 55 | #endif 56 | } 57 | 58 | #endif 59 | 60 | 61 | /* 62 | * Optional progress monitor: display a percent-done figure on stderr. 63 | */ 64 | 65 | #ifdef PROGRESS_REPORT 66 | 67 | METHODDEF(void) 68 | progress_monitor (j_common_ptr cinfo) 69 | { 70 | cd_progress_ptr prog = (cd_progress_ptr) cinfo->progress; 71 | int total_passes = prog->pub.total_passes + prog->total_extra_passes; 72 | int percent_done = (int) (prog->pub.pass_counter*100L/prog->pub.pass_limit); 73 | 74 | if (percent_done != prog->percent_done) { 75 | prog->percent_done = percent_done; 76 | if (total_passes > 1) { 77 | fprintf(stderr, "\rPass %d/%d: %3d%% ", 78 | prog->pub.completed_passes + prog->completed_extra_passes + 1, 79 | total_passes, percent_done); 80 | } else { 81 | fprintf(stderr, "\r %3d%% ", percent_done); 82 | } 83 | fflush(stderr); 84 | } 85 | } 86 | 87 | 88 | GLOBAL(void) 89 | start_progress_monitor (j_common_ptr cinfo, cd_progress_ptr progress) 90 | { 91 | /* Enable progress display, unless trace output is on */ 92 | if (cinfo->err->trace_level == 0) { 93 | progress->pub.progress_monitor = progress_monitor; 94 | progress->completed_extra_passes = 0; 95 | progress->total_extra_passes = 0; 96 | progress->percent_done = -1; 97 | cinfo->progress = &progress->pub; 98 | } 99 | } 100 | 101 | 102 | GLOBAL(void) 103 | end_progress_monitor (j_common_ptr cinfo) 104 | { 105 | /* Clear away progress display */ 106 | if (cinfo->err->trace_level == 0) { 107 | fprintf(stderr, "\r \r"); 108 | fflush(stderr); 109 | } 110 | } 111 | 112 | #endif 113 | 114 | 115 | /* 116 | * Case-insensitive matching of possibly-abbreviated keyword switches. 117 | * keyword is the constant keyword (must be lower case already), 118 | * minchars is length of minimum legal abbreviation. 119 | */ 120 | 121 | GLOBAL(boolean) 122 | keymatch (char * arg, const char * keyword, int minchars) 123 | { 124 | register int ca, ck; 125 | register int nmatched = 0; 126 | 127 | while ((ca = *arg++) != '\0') { 128 | if ((ck = *keyword++) == '\0') 129 | return FALSE; /* arg longer than keyword, no good */ 130 | if (isupper(ca)) /* force arg to lcase (assume ck is already) */ 131 | ca = tolower(ca); 132 | if (ca != ck) 133 | return FALSE; /* no good */ 134 | nmatched++; /* count matched characters */ 135 | } 136 | /* reached end of argument; fail if it's too short for unique abbrev */ 137 | if (nmatched < minchars) 138 | return FALSE; 139 | return TRUE; /* A-OK */ 140 | } 141 | 142 | 143 | /* 144 | * Routines to establish binary I/O mode for stdin and stdout. 145 | * Non-Unix systems often require some hacking to get out of text mode. 146 | */ 147 | 148 | GLOBAL(FILE *) 149 | read_stdin (void) 150 | { 151 | FILE * input_file = stdin; 152 | 153 | #ifdef USE_SETMODE /* need to hack file mode? */ 154 | setmode(fileno(stdin), O_BINARY); 155 | #endif 156 | #ifdef USE_FDOPEN /* need to re-open in binary mode? */ 157 | if ((input_file = fdopen(fileno(stdin), READ_BINARY)) == NULL) { 158 | fprintf(stderr, "Cannot reopen stdin\n"); 159 | exit(EXIT_FAILURE); 160 | } 161 | #endif 162 | return input_file; 163 | } 164 | 165 | 166 | GLOBAL(FILE *) 167 | write_stdout (void) 168 | { 169 | FILE * output_file = stdout; 170 | 171 | #ifdef USE_SETMODE /* need to hack file mode? */ 172 | setmode(fileno(stdout), O_BINARY); 173 | #endif 174 | #ifdef USE_FDOPEN /* need to re-open in binary mode? */ 175 | if ((output_file = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) { 176 | fprintf(stderr, "Cannot reopen stdout\n"); 177 | exit(EXIT_FAILURE); 178 | } 179 | #endif 180 | return output_file; 181 | } 182 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/jdtrans.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jdtrans.c 3 | * 4 | * Copyright (C) 1995-1997, Thomas G. Lane. 5 | * Modified 2000-2009 by Guido Vollbeding. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file contains library routines for transcoding decompression, 10 | * that is, reading raw DCT coefficient arrays from an input JPEG file. 11 | * The routines in jdapimin.c will also be needed by a transcoder. 12 | */ 13 | 14 | #define JPEG_INTERNALS 15 | #include "jinclude.h" 16 | #include "jpeglib.h" 17 | 18 | 19 | /* Forward declarations */ 20 | LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo)); 21 | 22 | 23 | /* 24 | * Read the coefficient arrays from a JPEG file. 25 | * jpeg_read_header must be completed before calling this. 26 | * 27 | * The entire image is read into a set of virtual coefficient-block arrays, 28 | * one per component. The return value is a pointer to the array of 29 | * virtual-array descriptors. These can be manipulated directly via the 30 | * JPEG memory manager, or handed off to jpeg_write_coefficients(). 31 | * To release the memory occupied by the virtual arrays, call 32 | * jpeg_finish_decompress() when done with the data. 33 | * 34 | * An alternative usage is to simply obtain access to the coefficient arrays 35 | * during a buffered-image-mode decompression operation. This is allowed 36 | * after any jpeg_finish_output() call. The arrays can be accessed until 37 | * jpeg_finish_decompress() is called. (Note that any call to the library 38 | * may reposition the arrays, so don't rely on access_virt_barray() results 39 | * to stay valid across library calls.) 40 | * 41 | * Returns NULL if suspended. This case need be checked only if 42 | * a suspending data source is used. 43 | */ 44 | 45 | GLOBAL(jvirt_barray_ptr *) 46 | jpeg_read_coefficients (j_decompress_ptr cinfo) 47 | { 48 | if (cinfo->global_state == DSTATE_READY) { 49 | /* First call: initialize active modules */ 50 | transdecode_master_selection(cinfo); 51 | cinfo->global_state = DSTATE_RDCOEFS; 52 | } 53 | if (cinfo->global_state == DSTATE_RDCOEFS) { 54 | /* Absorb whole file into the coef buffer */ 55 | for (;;) { 56 | int retcode; 57 | /* Call progress monitor hook if present */ 58 | if (cinfo->progress != NULL) 59 | (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); 60 | /* Absorb some more input */ 61 | retcode = (*cinfo->inputctl->consume_input) (cinfo); 62 | if (retcode == JPEG_SUSPENDED) 63 | return NULL; 64 | if (retcode == JPEG_REACHED_EOI) 65 | break; 66 | /* Advance progress counter if appropriate */ 67 | if (cinfo->progress != NULL && 68 | (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { 69 | if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { 70 | /* startup underestimated number of scans; ratchet up one scan */ 71 | cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; 72 | } 73 | } 74 | } 75 | /* Set state so that jpeg_finish_decompress does the right thing */ 76 | cinfo->global_state = DSTATE_STOPPING; 77 | } 78 | /* At this point we should be in state DSTATE_STOPPING if being used 79 | * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access 80 | * to the coefficients during a full buffered-image-mode decompression. 81 | */ 82 | if ((cinfo->global_state == DSTATE_STOPPING || 83 | cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) { 84 | return cinfo->coef->coef_arrays; 85 | } 86 | /* Oops, improper usage */ 87 | ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 88 | return NULL; /* keep compiler happy */ 89 | } 90 | 91 | 92 | /* 93 | * Master selection of decompression modules for transcoding. 94 | * This substitutes for jdmaster.c's initialization of the full decompressor. 95 | */ 96 | 97 | LOCAL(void) 98 | transdecode_master_selection (j_decompress_ptr cinfo) 99 | { 100 | /* This is effectively a buffered-image operation. */ 101 | cinfo->buffered_image = TRUE; 102 | 103 | /* Compute output image dimensions and related values. */ 104 | jpeg_core_output_dimensions(cinfo); 105 | 106 | /* Entropy decoding: either Huffman or arithmetic coding. */ 107 | if (cinfo->arith_code) 108 | jinit_arith_decoder(cinfo); 109 | else { 110 | jinit_huff_decoder(cinfo); 111 | } 112 | 113 | /* Always get a full-image coefficient buffer. */ 114 | jinit_d_coef_controller(cinfo, TRUE); 115 | 116 | /* We can now tell the memory manager to allocate virtual arrays. */ 117 | (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); 118 | 119 | /* Initialize input side of decompressor to consume first scan. */ 120 | (*cinfo->inputctl->start_input_pass) (cinfo); 121 | 122 | /* Initialize progress monitoring. */ 123 | if (cinfo->progress != NULL) { 124 | int nscans; 125 | /* Estimate number of scans to set pass_limit. */ 126 | if (cinfo->progressive_mode) { 127 | /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ 128 | nscans = 2 + 3 * cinfo->num_components; 129 | } else if (cinfo->inputctl->has_multiple_scans) { 130 | /* For a nonprogressive multiscan file, estimate 1 scan per component. */ 131 | nscans = cinfo->num_components; 132 | } else { 133 | nscans = 1; 134 | } 135 | cinfo->progress->pass_counter = 0L; 136 | cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; 137 | cinfo->progress->completed_passes = 0; 138 | cinfo->progress->total_passes = 1; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/jaricom.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jaricom.c 3 | * 4 | * Developed 1997-2011 by Guido Vollbeding. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains probability estimation tables for common use in 9 | * arithmetic entropy encoding and decoding routines. 10 | * 11 | * This data represents Table D.3 in the JPEG spec (D.2 in the draft), 12 | * ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81, and Table 24 13 | * in the JBIG spec, ISO/IEC IS 11544 and CCITT Recommendation ITU-T T.82. 14 | */ 15 | 16 | #define JPEG_INTERNALS 17 | #include "jinclude.h" 18 | #include "jpeglib.h" 19 | 20 | /* The following #define specifies the packing of the four components 21 | * into the compact INT32 representation. 22 | * Note that this formula must match the actual arithmetic encoder 23 | * and decoder implementation. The implementation has to be changed 24 | * if this formula is changed. 25 | * The current organization is leaned on Markus Kuhn's JBIG 26 | * implementation (jbig_tab.c). 27 | */ 28 | 29 | #define V(i,a,b,c,d) (((INT32)a << 16) | ((INT32)c << 8) | ((INT32)d << 7) | b) 30 | 31 | const INT32 jpeg_aritab[113+1] = { 32 | /* 33 | * Index, Qe_Value, Next_Index_LPS, Next_Index_MPS, Switch_MPS 34 | */ 35 | V( 0, 0x5a1d, 1, 1, 1 ), 36 | V( 1, 0x2586, 14, 2, 0 ), 37 | V( 2, 0x1114, 16, 3, 0 ), 38 | V( 3, 0x080b, 18, 4, 0 ), 39 | V( 4, 0x03d8, 20, 5, 0 ), 40 | V( 5, 0x01da, 23, 6, 0 ), 41 | V( 6, 0x00e5, 25, 7, 0 ), 42 | V( 7, 0x006f, 28, 8, 0 ), 43 | V( 8, 0x0036, 30, 9, 0 ), 44 | V( 9, 0x001a, 33, 10, 0 ), 45 | V( 10, 0x000d, 35, 11, 0 ), 46 | V( 11, 0x0006, 9, 12, 0 ), 47 | V( 12, 0x0003, 10, 13, 0 ), 48 | V( 13, 0x0001, 12, 13, 0 ), 49 | V( 14, 0x5a7f, 15, 15, 1 ), 50 | V( 15, 0x3f25, 36, 16, 0 ), 51 | V( 16, 0x2cf2, 38, 17, 0 ), 52 | V( 17, 0x207c, 39, 18, 0 ), 53 | V( 18, 0x17b9, 40, 19, 0 ), 54 | V( 19, 0x1182, 42, 20, 0 ), 55 | V( 20, 0x0cef, 43, 21, 0 ), 56 | V( 21, 0x09a1, 45, 22, 0 ), 57 | V( 22, 0x072f, 46, 23, 0 ), 58 | V( 23, 0x055c, 48, 24, 0 ), 59 | V( 24, 0x0406, 49, 25, 0 ), 60 | V( 25, 0x0303, 51, 26, 0 ), 61 | V( 26, 0x0240, 52, 27, 0 ), 62 | V( 27, 0x01b1, 54, 28, 0 ), 63 | V( 28, 0x0144, 56, 29, 0 ), 64 | V( 29, 0x00f5, 57, 30, 0 ), 65 | V( 30, 0x00b7, 59, 31, 0 ), 66 | V( 31, 0x008a, 60, 32, 0 ), 67 | V( 32, 0x0068, 62, 33, 0 ), 68 | V( 33, 0x004e, 63, 34, 0 ), 69 | V( 34, 0x003b, 32, 35, 0 ), 70 | V( 35, 0x002c, 33, 9, 0 ), 71 | V( 36, 0x5ae1, 37, 37, 1 ), 72 | V( 37, 0x484c, 64, 38, 0 ), 73 | V( 38, 0x3a0d, 65, 39, 0 ), 74 | V( 39, 0x2ef1, 67, 40, 0 ), 75 | V( 40, 0x261f, 68, 41, 0 ), 76 | V( 41, 0x1f33, 69, 42, 0 ), 77 | V( 42, 0x19a8, 70, 43, 0 ), 78 | V( 43, 0x1518, 72, 44, 0 ), 79 | V( 44, 0x1177, 73, 45, 0 ), 80 | V( 45, 0x0e74, 74, 46, 0 ), 81 | V( 46, 0x0bfb, 75, 47, 0 ), 82 | V( 47, 0x09f8, 77, 48, 0 ), 83 | V( 48, 0x0861, 78, 49, 0 ), 84 | V( 49, 0x0706, 79, 50, 0 ), 85 | V( 50, 0x05cd, 48, 51, 0 ), 86 | V( 51, 0x04de, 50, 52, 0 ), 87 | V( 52, 0x040f, 50, 53, 0 ), 88 | V( 53, 0x0363, 51, 54, 0 ), 89 | V( 54, 0x02d4, 52, 55, 0 ), 90 | V( 55, 0x025c, 53, 56, 0 ), 91 | V( 56, 0x01f8, 54, 57, 0 ), 92 | V( 57, 0x01a4, 55, 58, 0 ), 93 | V( 58, 0x0160, 56, 59, 0 ), 94 | V( 59, 0x0125, 57, 60, 0 ), 95 | V( 60, 0x00f6, 58, 61, 0 ), 96 | V( 61, 0x00cb, 59, 62, 0 ), 97 | V( 62, 0x00ab, 61, 63, 0 ), 98 | V( 63, 0x008f, 61, 32, 0 ), 99 | V( 64, 0x5b12, 65, 65, 1 ), 100 | V( 65, 0x4d04, 80, 66, 0 ), 101 | V( 66, 0x412c, 81, 67, 0 ), 102 | V( 67, 0x37d8, 82, 68, 0 ), 103 | V( 68, 0x2fe8, 83, 69, 0 ), 104 | V( 69, 0x293c, 84, 70, 0 ), 105 | V( 70, 0x2379, 86, 71, 0 ), 106 | V( 71, 0x1edf, 87, 72, 0 ), 107 | V( 72, 0x1aa9, 87, 73, 0 ), 108 | V( 73, 0x174e, 72, 74, 0 ), 109 | V( 74, 0x1424, 72, 75, 0 ), 110 | V( 75, 0x119c, 74, 76, 0 ), 111 | V( 76, 0x0f6b, 74, 77, 0 ), 112 | V( 77, 0x0d51, 75, 78, 0 ), 113 | V( 78, 0x0bb6, 77, 79, 0 ), 114 | V( 79, 0x0a40, 77, 48, 0 ), 115 | V( 80, 0x5832, 80, 81, 1 ), 116 | V( 81, 0x4d1c, 88, 82, 0 ), 117 | V( 82, 0x438e, 89, 83, 0 ), 118 | V( 83, 0x3bdd, 90, 84, 0 ), 119 | V( 84, 0x34ee, 91, 85, 0 ), 120 | V( 85, 0x2eae, 92, 86, 0 ), 121 | V( 86, 0x299a, 93, 87, 0 ), 122 | V( 87, 0x2516, 86, 71, 0 ), 123 | V( 88, 0x5570, 88, 89, 1 ), 124 | V( 89, 0x4ca9, 95, 90, 0 ), 125 | V( 90, 0x44d9, 96, 91, 0 ), 126 | V( 91, 0x3e22, 97, 92, 0 ), 127 | V( 92, 0x3824, 99, 93, 0 ), 128 | V( 93, 0x32b4, 99, 94, 0 ), 129 | V( 94, 0x2e17, 93, 86, 0 ), 130 | V( 95, 0x56a8, 95, 96, 1 ), 131 | V( 96, 0x4f46, 101, 97, 0 ), 132 | V( 97, 0x47e5, 102, 98, 0 ), 133 | V( 98, 0x41cf, 103, 99, 0 ), 134 | V( 99, 0x3c3d, 104, 100, 0 ), 135 | V( 100, 0x375e, 99, 93, 0 ), 136 | V( 101, 0x5231, 105, 102, 0 ), 137 | V( 102, 0x4c0f, 106, 103, 0 ), 138 | V( 103, 0x4639, 107, 104, 0 ), 139 | V( 104, 0x415e, 103, 99, 0 ), 140 | V( 105, 0x5627, 105, 106, 1 ), 141 | V( 106, 0x50e7, 108, 107, 0 ), 142 | V( 107, 0x4b85, 109, 103, 0 ), 143 | V( 108, 0x5597, 110, 109, 0 ), 144 | V( 109, 0x504f, 111, 107, 0 ), 145 | V( 110, 0x5a10, 110, 111, 1 ), 146 | V( 111, 0x5522, 112, 109, 0 ), 147 | V( 112, 0x59eb, 112, 111, 1 ), 148 | /* 149 | * This last entry is used for fixed probability estimate of 0.5 150 | * as suggested in Section 10.3 Table 5 of ITU-T Rec. T.851. 151 | */ 152 | V( 113, 0x5a1d, 113, 113, 0 ) 153 | }; 154 | -------------------------------------------------------------------------------- /FlirOneControl/system.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "system.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | //**************************************************************************************************** 13 | //реализация функций 14 | //**************************************************************************************************** 15 | 16 | //---------------------------------------------------------------------------------------------------- 17 | //создать список файлов директории 18 | //---------------------------------------------------------------------------------------------------- 19 | void CreateFileList(const std::string &path,std::vector &vector_file_name) 20 | { 21 | vector_file_name.clear(); 22 | //сканируем файлы каталога 23 | DIR *dir; 24 | dirent *d_ptr; 25 | dir=opendir(path.c_str()); 26 | if (dir!=NULL) 27 | { 28 | while(1) 29 | { 30 | d_ptr=readdir(dir); 31 | if (d_ptr==NULL) break; 32 | long len=strlen(d_ptr->d_name); 33 | if (len==1) 34 | { 35 | if (d_ptr->d_name[len-1]=='.') continue; 36 | } 37 | if (len==2) 38 | { 39 | if (d_ptr->d_name[len-1]=='.' && d_ptr->d_name[len-2]=='.') continue; 40 | } 41 | std::string filename=path; 42 | filename+=GetPathDivider(); 43 | filename+=d_ptr->d_name; 44 | 45 | DIR *dir_tmp; 46 | dirent *d_tmp_ptr; 47 | dir_tmp=opendir(filename.c_str()); 48 | if (dir_tmp!=NULL)//это каталог, а не файл 49 | { 50 | closedir(dir_tmp); 51 | continue; 52 | } 53 | //vector_file_name.push_back(filename); 54 | vector_file_name.push_back(d_ptr->d_name); 55 | } 56 | closedir(dir); 57 | } 58 | } 59 | 60 | //---------------------------------------------------------------------------------------------------- 61 | //создать список каталогов директории 62 | //---------------------------------------------------------------------------------------------------- 63 | void CreateDirectoryList(const std::string &path,std::vector &vector_directory_name) 64 | { 65 | vector_directory_name.clear(); 66 | //сканируем директории каталога 67 | DIR *dir; 68 | dirent *d_ptr; 69 | dir=opendir(path.c_str()); 70 | if (dir!=NULL) 71 | { 72 | while(1) 73 | { 74 | d_ptr=readdir(dir); 75 | if (d_ptr==NULL) break; 76 | long len=strlen(d_ptr->d_name); 77 | if (len==1) 78 | { 79 | if (d_ptr->d_name[len-1]=='.') continue; 80 | } 81 | if (len==2) 82 | { 83 | if (d_ptr->d_name[len-1]=='.' && d_ptr->d_name[len-2]=='.') continue; 84 | } 85 | std::string filename=path; 86 | filename+=GetPathDivider(); 87 | filename+=d_ptr->d_name; 88 | 89 | DIR *dir_tmp; 90 | dirent *d_tmp_ptr; 91 | dir_tmp=opendir(filename.c_str()); 92 | if (dir_tmp==NULL) continue;//это файл,а не каталог 93 | closedir(dir_tmp); 94 | //vector_directory_name.push_back(filename); 95 | vector_directory_name.push_back(d_ptr->d_name); 96 | } 97 | closedir(dir); 98 | } 99 | } 100 | 101 | //---------------------------------------------------------------------------------------------------- 102 | //создать каталог 103 | //---------------------------------------------------------------------------------------------------- 104 | void MakeDirectory(const std::string &directory_name) 105 | { 106 | mkdir(directory_name.c_str(),S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH |S_IXOTH); 107 | } 108 | 109 | //---------------------------------------------------------------------------------------------------- 110 | //получить прошедшее время в секундах 111 | //---------------------------------------------------------------------------------------------------- 112 | long double GetSecondCounter(void) 113 | { 114 | const long double ticks=static_cast(sysconf(_SC_CLK_TCK)); 115 | struct tms tms; 116 | if (times(&tms)!=(clock_t)-1) return(static_cast(tms.tms_utime)/ticks); 117 | return(0); 118 | } 119 | //---------------------------------------------------------------------------------------------------- 120 | //пауза в миллисекундах 121 | //---------------------------------------------------------------------------------------------------- 122 | void PauseInMs(size_t ms) 123 | { 124 | usleep(ms*1000); 125 | } 126 | //---------------------------------------------------------------------------------------------------- 127 | //пауза в микросекундах 128 | //---------------------------------------------------------------------------------------------------- 129 | void PauseInUs(size_t us) 130 | { 131 | usleep(us); 132 | } 133 | //---------------------------------------------------------------------------------------------------- 134 | //получить текущую директорию 135 | //---------------------------------------------------------------------------------------------------- 136 | std::string GetCurrentPath(void) 137 | { 138 | return(std::string(".")); 139 | } 140 | //---------------------------------------------------------------------------------------------------- 141 | //получить разделитель каталого 142 | //---------------------------------------------------------------------------------------------------- 143 | std::string GetPathDivider(void) 144 | { 145 | return(std::string("/")); 146 | } 147 | //---------------------------------------------------------------------------------------------------- 148 | //вывести сообщение 149 | //---------------------------------------------------------------------------------------------------- 150 | void PutMessage(const std::string &message) 151 | { 152 | printf("%s\r\n",message.c_str()); 153 | } 154 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/cderror.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cderror.h 3 | * 4 | * Copyright (C) 1994-1997, Thomas G. Lane. 5 | * Modified 2009-2017 by Guido Vollbeding. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file defines the error and message codes for the cjpeg/djpeg 10 | * applications. These strings are not needed as part of the JPEG library 11 | * proper. 12 | * Edit this file to add new codes, or to translate the message strings to 13 | * some other language. 14 | */ 15 | 16 | /* 17 | * To define the enum list of message codes, include this file without 18 | * defining macro JMESSAGE. To create a message string table, include it 19 | * again with a suitable JMESSAGE definition (see jerror.c for an example). 20 | */ 21 | #ifndef JMESSAGE 22 | #ifndef CDERROR_H 23 | #define CDERROR_H 24 | /* First time through, define the enum list */ 25 | #define JMAKE_ENUM_LIST 26 | #else 27 | /* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ 28 | #define JMESSAGE(code,string) 29 | #endif /* CDERROR_H */ 30 | #endif /* JMESSAGE */ 31 | 32 | #ifdef JMAKE_ENUM_LIST 33 | 34 | typedef enum { 35 | 36 | #define JMESSAGE(code,string) code , 37 | 38 | #endif /* JMAKE_ENUM_LIST */ 39 | 40 | JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */ 41 | 42 | #ifdef BMP_SUPPORTED 43 | JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format") 44 | JMESSAGE(JERR_BMP_BADDEPTH, "Only 8-, 24-, and 32-bit BMP files are supported") 45 | JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length") 46 | JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1") 47 | JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB") 48 | JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported") 49 | JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM") 50 | JMESSAGE(JERR_BMP_OUTOFRANGE, "Numeric value out of range in BMP file") 51 | JMESSAGE(JTRC_BMP, "%ux%u %d-bit BMP image") 52 | JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image") 53 | JMESSAGE(JTRC_BMP_OS2, "%ux%u %d-bit OS2 BMP image") 54 | JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image") 55 | #endif /* BMP_SUPPORTED */ 56 | 57 | #ifdef GIF_SUPPORTED 58 | JMESSAGE(JERR_GIF_BUG, "GIF output got confused") 59 | JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d") 60 | JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB") 61 | JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file") 62 | JMESSAGE(JERR_GIF_NOT, "Not a GIF file") 63 | JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image") 64 | JMESSAGE(JTRC_GIF_BADVERSION, 65 | "Warning: unexpected GIF version number '%c%c%c'") 66 | JMESSAGE(JTRC_GIF_EXTENSION, "Ignoring GIF extension block of type 0x%02x") 67 | JMESSAGE(JTRC_GIF_NONSQUARE, "Caution: nonsquare pixels in input") 68 | JMESSAGE(JWRN_GIF_BADDATA, "Corrupt data in GIF file") 69 | JMESSAGE(JWRN_GIF_CHAR, "Bogus char 0x%02x in GIF file, ignoring") 70 | JMESSAGE(JWRN_GIF_ENDCODE, "Premature end of GIF image") 71 | JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits") 72 | #endif /* GIF_SUPPORTED */ 73 | 74 | #ifdef PPM_SUPPORTED 75 | JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB") 76 | JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file") 77 | JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file") 78 | JMESSAGE(JERR_PPM_OUTOFRANGE, "Numeric value out of range in PPM file") 79 | JMESSAGE(JTRC_PGM, "%ux%u PGM image") 80 | JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image") 81 | JMESSAGE(JTRC_PPM, "%ux%u PPM image") 82 | JMESSAGE(JTRC_PPM_TEXT, "%ux%u text PPM image") 83 | #endif /* PPM_SUPPORTED */ 84 | 85 | #ifdef RLE_SUPPORTED 86 | JMESSAGE(JERR_RLE_BADERROR, "Bogus error code from RLE library") 87 | JMESSAGE(JERR_RLE_COLORSPACE, "RLE output must be grayscale or RGB") 88 | JMESSAGE(JERR_RLE_DIMENSIONS, "Image dimensions (%ux%u) too large for RLE") 89 | JMESSAGE(JERR_RLE_EMPTY, "Empty RLE file") 90 | JMESSAGE(JERR_RLE_EOF, "Premature EOF in RLE header") 91 | JMESSAGE(JERR_RLE_MEM, "Insufficient memory for RLE header") 92 | JMESSAGE(JERR_RLE_NOT, "Not an RLE file") 93 | JMESSAGE(JERR_RLE_TOOMANYCHANNELS, "Cannot handle %d output channels for RLE") 94 | JMESSAGE(JERR_RLE_UNSUPPORTED, "Cannot handle this RLE setup") 95 | JMESSAGE(JTRC_RLE, "%ux%u full-color RLE file") 96 | JMESSAGE(JTRC_RLE_FULLMAP, "%ux%u full-color RLE file with map of length %d") 97 | JMESSAGE(JTRC_RLE_GRAY, "%ux%u grayscale RLE file") 98 | JMESSAGE(JTRC_RLE_MAPGRAY, "%ux%u grayscale RLE file with map of length %d") 99 | JMESSAGE(JTRC_RLE_MAPPED, "%ux%u colormapped RLE file with map of length %d") 100 | #endif /* RLE_SUPPORTED */ 101 | 102 | #ifdef TARGA_SUPPORTED 103 | JMESSAGE(JERR_TGA_BADCMAP, "Unsupported Targa colormap format") 104 | JMESSAGE(JERR_TGA_BADPARMS, "Invalid or unsupported Targa file") 105 | JMESSAGE(JERR_TGA_COLORSPACE, "Targa output must be grayscale or RGB") 106 | JMESSAGE(JTRC_TGA, "%ux%u RGB Targa image") 107 | JMESSAGE(JTRC_TGA_GRAY, "%ux%u grayscale Targa image") 108 | JMESSAGE(JTRC_TGA_MAPPED, "%ux%u colormapped Targa image") 109 | #else 110 | JMESSAGE(JERR_TGA_NOTCOMP, "Targa support was not compiled") 111 | #endif /* TARGA_SUPPORTED */ 112 | 113 | JMESSAGE(JERR_BAD_CMAP_FILE, 114 | "Color map file is invalid or of unsupported format") 115 | JMESSAGE(JERR_TOO_MANY_COLORS, 116 | "Output file format cannot handle %d colormap entries") 117 | JMESSAGE(JERR_UNGETC_FAILED, "ungetc failed") 118 | #ifdef TARGA_SUPPORTED 119 | JMESSAGE(JERR_UNKNOWN_FORMAT, 120 | "Unrecognized input file format --- perhaps you need -targa") 121 | #else 122 | JMESSAGE(JERR_UNKNOWN_FORMAT, "Unrecognized input file format") 123 | #endif 124 | JMESSAGE(JERR_UNSUPPORTED_FORMAT, "Unsupported output file format") 125 | 126 | #ifdef JMAKE_ENUM_LIST 127 | 128 | JMSG_LASTADDONCODE 129 | } ADDON_MESSAGE_CODE; 130 | 131 | #undef JMAKE_ENUM_LIST 132 | #endif /* JMAKE_ENUM_LIST */ 133 | 134 | /* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ 135 | #undef JMESSAGE 136 | -------------------------------------------------------------------------------- /FlirOneControl/cdecorator_scale.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "cdecorator_scale.h" 5 | #include 6 | 7 | //**************************************************************************************************** 8 | //глобальные переменные 9 | //**************************************************************************************************** 10 | 11 | //**************************************************************************************************** 12 | //константы 13 | //**************************************************************************************************** 14 | 15 | //**************************************************************************************************** 16 | //макроопределения 17 | //**************************************************************************************************** 18 | 19 | //**************************************************************************************************** 20 | //конструктор и деструктор 21 | //**************************************************************************************************** 22 | 23 | //---------------------------------------------------------------------------------------------------- 24 | //конструктор 25 | //---------------------------------------------------------------------------------------------------- 26 | CDecorator_Scale::CDecorator_Scale(IImage *iImage_Set_Ptr,uint32_t new_width,uint32_t new_height):CDecorator_IImage(iImage_Set_Ptr) 27 | { 28 | Width=new_width; 29 | Height=new_height; 30 | } 31 | //---------------------------------------------------------------------------------------------------- 32 | //деструктор 33 | //---------------------------------------------------------------------------------------------------- 34 | CDecorator_Scale::~CDecorator_Scale() 35 | { 36 | } 37 | 38 | //**************************************************************************************************** 39 | //закрытые функции 40 | //**************************************************************************************************** 41 | 42 | //**************************************************************************************************** 43 | //открытые функции 44 | //**************************************************************************************************** 45 | 46 | //---------------------------------------------------------------------------------------------------- 47 | //получить RGBA изображение 48 | //---------------------------------------------------------------------------------------------------- 49 | void CDecorator_Scale::GetRGBAImage(uint32_t &width,uint32_t &height,std::vector &vector_image) 50 | { 51 | //создаём увеличенное изображение 52 | std::vector vector_oldimage;//данные изображения 53 | //запрашиваем изображение 54 | CDecorator_IImage::GetRGBAImage(width,height,vector_oldimage); 55 | //производим масштабирование 56 | uint32_t x; 57 | uint32_t y; 58 | vector_image.resize(Width*Height); 59 | 60 | uint32_t *i_ptr=&(vector_image[0]); 61 | uint32_t *oldi_ptr=&(vector_oldimage[0]); 62 | for(y=0;y(y)/static_cast(Height-1)*static_cast(height-1); 65 | int32_t ys=static_cast(floor(tmp)); 66 | if (ys<0) ys=0; 67 | if (ys>=height-1) ys=height-2; 68 | float u=tmp-ys; 69 | for(x=0;x(x)/static_cast(Width-1)*static_cast(width-1); 72 | int32_t xs=static_cast(floor(tmp)); 73 | if (xs<0) xs=0; 74 | if (xs>=width-1) xs=width-2; 75 | float v=tmp-xs; 76 | //коэффициенты 77 | float d1=(1-v)*(1-u); 78 | float d2=v*(1-u); 79 | float d3=v*u; 80 | float d4=(1-v)*u; 81 | //окрестные пиксели 82 | uint32_t p1=oldi_ptr[xs+ys*width]; 83 | uint32_t p2=oldi_ptr[xs+1+ys*width]; 84 | uint32_t p3=oldi_ptr[xs+1+(ys+1)*width]; 85 | uint32_t p4=oldi_ptr[xs+(ys+1)*width]; 86 | //вычисляем новое значение пикселя 87 | uint32_t color=0; 88 | uint32_t mask=0xFF; 89 | uint32_t offset=0; 90 | for(uint8_t k=0;k<4;k++,mask<<=8,offset+=8) 91 | { 92 | uint32_t kp1=(p1&mask)>>offset; 93 | uint32_t kp2=(p2&mask)>>offset; 94 | uint32_t kp3=(p3&mask)>>offset; 95 | uint32_t kp4=(p4&mask)>>offset; 96 | uint32_t c=static_cast(kp1*d1+kp2*d2+kp3*d3+kp4*d4); 97 | if (c>=0xFF) c=0xFF; 98 | color|=(c< &vector_image) 110 | { 111 | CDecorator_IImage::SetRGBAImage(width,height,vector_image); 112 | } 113 | //---------------------------------------------------------------------------------------------------- 114 | //задать размер изображения 115 | //---------------------------------------------------------------------------------------------------- 116 | void CDecorator_Scale::SetSize(uint32_t width,uint32_t height) 117 | { 118 | Width=width; 119 | Height=height; 120 | //CDecorator_IImage::SetSize(width,height); 121 | } 122 | //---------------------------------------------------------------------------------------------------- 123 | //задать точку 124 | //---------------------------------------------------------------------------------------------------- 125 | void CDecorator_Scale::SetRGBAPixel(uint32_t x,uint32_t y,uint32_t color) 126 | { 127 | CDecorator_IImage::SetRGBAPixel(x,y,color); 128 | } 129 | //---------------------------------------------------------------------------------------------------- 130 | //получить точку 131 | //---------------------------------------------------------------------------------------------------- 132 | uint32_t CDecorator_Scale::GetRGBAPixel(uint32_t x,uint32_t y) 133 | { 134 | return(CDecorator_IImage::GetRGBAPixel(x,y)); 135 | } 136 | -------------------------------------------------------------------------------- /FlirOneControl/cflironereceiver.h: -------------------------------------------------------------------------------- 1 | #ifndef C_FLIR_ONE_RECEIVER_H 2 | #define C_FLIR_ONE_RECEIVER_H 3 | 4 | //**************************************************************************************************** 5 | //Класс приёма данных от Flir One 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "cringbuffer.h" 16 | #include "libjpeg/jpeglib.h" 17 | 18 | //**************************************************************************************************** 19 | //макроопределения 20 | //**************************************************************************************************** 21 | 22 | //**************************************************************************************************** 23 | //константы 24 | //**************************************************************************************************** 25 | 26 | //**************************************************************************************************** 27 | //предварительные объявления 28 | //**************************************************************************************************** 29 | 30 | //**************************************************************************************************** 31 | //Класс приёма данных от Flir One 32 | //**************************************************************************************************** 33 | class CFlirOneReceiver 34 | { 35 | public: 36 | //-перечисления--------------------------------------------------------------------------------------- 37 | //-структуры------------------------------------------------------------------------------------------ 38 | //-константы------------------------------------------------------------------------------------------ 39 | 40 | //размер буфера приёма данных 41 | static const int32_t IMAGE_BUFFER_SIZE=1048576; 42 | 43 | //исходные размеры изображения (не перевёрнутые) 44 | static const int32_t ORIGINAL_IMAGE_WIDTH=160; 45 | static const int32_t ORIGINAL_IMAGE_HEIGHT=120; 46 | 47 | //исходные размеры видео (не перевёрнутые) 48 | static const int32_t ORIGINAL_VIDEO_WIDTH=640; 49 | static const int32_t ORIGINAL_VIDEO_HEIGHT=480; 50 | 51 | //размеры изображения после обработки и переворота в вертикальное положение 52 | static const int32_t IMAGE_WIDTH=120; 53 | static const int32_t IMAGE_HEIGHT=160; 54 | 55 | //размеры видео после обработки 56 | static const int32_t VIDEO_WIDTH=480; 57 | static const int32_t VIDEO_HEIGHT=640; 58 | 59 | //размер изображений 60 | static const int32_t THERMAL_IMAGE_SIZE=(IMAGE_WIDTH*IMAGE_HEIGHT); 61 | static const int32_t COLOR_IMAGE_SIZE=(IMAGE_WIDTH*IMAGE_HEIGHT); 62 | static const int32_t VIDEO_IMAGE_SIZE=(VIDEO_WIDTH*VIDEO_HEIGHT); 63 | 64 | static const int32_t COLOR_MAP_UNIT=256;//количество цветов в палитре 65 | static const int32_t COLOR_SIZE=3;//число байт на один цвет (RGB) 66 | static const int32_t MAX_COLOR_INDEX=(COLOR_MAP_UNIT-1);//максимальный индекс цвета 67 | private: 68 | //-структуры------------------------------------------------------------------------------------------ 69 | 70 | #pragma pack(1) 71 | //заголовок кадра тепловизора 72 | struct SHeader 73 | { 74 | uint8_t MagicByte[4];//магические байты 75 | uint8_t Unknow1[4];//неизвестные данные 76 | uint32_t FrameSize;//полный размер кадра 77 | uint32_t ThermalSize;//размер кадра тепловизора 78 | uint32_t JpgSize;//размер изображения с камеры 79 | uint32_t StatusSize;//размер слова состояния 80 | uint8_t Unknow2[4];//неизвестные данные 81 | }; 82 | #pragma pack() 83 | 84 | //-переменные----------------------------------------------------------------------------------------- 85 | 86 | //палитра перекодировки изображения 87 | uint8_t ColorMap_R[COLOR_MAP_UNIT]; 88 | uint8_t ColorMap_G[COLOR_MAP_UNIT]; 89 | uint8_t ColorMap_B[COLOR_MAP_UNIT]; 90 | 91 | std::unique_ptr cRingBuffer_Ptr;//кольцевой буфер приёма данных 92 | 93 | SHeader sHeader;//заголовок пакета 94 | bool HeaderIsReceived;//заголовок принят 95 | 96 | uint8_t MagicPos;//позиция анализируемого магического байта 97 | uint32_t MagicHeadPos;//позиция головы, когда встречился первый магический байт 98 | 99 | std::vector ThermalImage;//тепловое изображение (raw14) 100 | std::vector VideoImage;//изображение с видеокамеры 101 | std::vector ColorImage;//раскрашенное изображение 102 | 103 | std::vector JPGImage;//прямые данные с видеокамеры (картинка в jpg) 104 | 105 | long FrameIndex;//номер текущего кадра 106 | 107 | bool ShowVideo;//показывать ли видео 108 | public: 109 | //-конструктор---------------------------------------------------------------------------------------- 110 | CFlirOneReceiver(void); 111 | //-деструктор----------------------------------------------------------------------------------------- 112 | ~CFlirOneReceiver(); 113 | public: 114 | //-открытые функции----------------------------------------------------------------------------------- 115 | bool LoadColorMap(const std::string &filename);//загрузить карту перекодировки изображения 116 | bool CopyColorImage(std::vector &image,uint32_t &index);//скопировать раскрашенное изображение в буфер 117 | bool CopyThermalImage(std::vector &image,uint32_t &index);//скопировать тепловое изображение в буфер 118 | bool CopyVideoImage(std::vector &image,uint32_t &index);//скопировать изображение с видеокамеры в буфер 119 | bool CopyJPGImage(std::vector &vector_jpg,uint32_t &index);//скопировать данные с видеокамеры в буфер 120 | bool CopyColorMap(uint8_t R[COLOR_MAP_UNIT],uint8_t G[COLOR_MAP_UNIT],uint8_t B[COLOR_MAP_UNIT],uint32_t size);//скопировать палитру 121 | bool CreateImage(uint8_t *buffer,uint32_t size);//создать изображение 122 | void SetShowVideo(bool state);//показывать ли видео 123 | private: 124 | //-закрытые функции----------------------------------------------------------------------------------- 125 | void CalculateCRC(uint16_t &crc,uint8_t byte);//вычислить crc 126 | }; 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /FlirOneControl/cringbuffer.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "cringbuffer.h" 5 | 6 | //**************************************************************************************************** 7 | //глобальные переменные 8 | //**************************************************************************************************** 9 | 10 | //**************************************************************************************************** 11 | //константы 12 | //**************************************************************************************************** 13 | 14 | //**************************************************************************************************** 15 | //макроопределения 16 | //**************************************************************************************************** 17 | 18 | //**************************************************************************************************** 19 | //конструктор и деструктор 20 | //**************************************************************************************************** 21 | 22 | //---------------------------------------------------------------------------------------------------- 23 | //конструктор 24 | //---------------------------------------------------------------------------------------------------- 25 | CRingBuffer::CRingBuffer(uint32_t size) 26 | { 27 | Buffer=new uint8_t[size+1]; 28 | Reset(); 29 | Size=size; 30 | } 31 | //---------------------------------------------------------------------------------------------------- 32 | //деструктор 33 | //---------------------------------------------------------------------------------------------------- 34 | CRingBuffer::~CRingBuffer() 35 | { 36 | delete[](Buffer); 37 | } 38 | 39 | //**************************************************************************************************** 40 | //закрытые функции 41 | //**************************************************************************************************** 42 | 43 | //**************************************************************************************************** 44 | //открытые функции 45 | //**************************************************************************************************** 46 | 47 | //---------------------------------------------------------------------------------------------------- 48 | //добавить байт в кольцевой буфер 49 | //---------------------------------------------------------------------------------------------------- 50 | void CRingBuffer::PushByte(uint8_t b) 51 | { 52 | Buffer[Head]=b; 53 | Head++; 54 | if (Head==Size) Head=0; 55 | if (Head==Tail) Tail++; 56 | if (Tail==Size) Tail=0; 57 | } 58 | //---------------------------------------------------------------------------------------------------- 59 | //забрать байт из кольцевого буфера 60 | //---------------------------------------------------------------------------------------------------- 61 | bool CRingBuffer::PopByte(uint8_t *b) 62 | { 63 | if (Head==Tail) return(false); 64 | *b=Buffer[Tail]; 65 | Tail++; 66 | if (Tail==Size) Tail=0; 67 | return(true); 68 | } 69 | 70 | //---------------------------------------------------------------------------------------------------- 71 | //забрать два байта из кольцевого буфера 72 | //---------------------------------------------------------------------------------------------------- 73 | bool CRingBuffer::PopShort(uint16_t *s) 74 | { 75 | if (PopByte((uint8_t*)(s)+0)==false) return(false); 76 | if (PopByte((uint8_t*)(s)+1)==false) return(false); 77 | return(true); 78 | } 79 | 80 | //---------------------------------------------------------------------------------------------------- 81 | //получить сколько байт в кольцевом буфере 82 | //---------------------------------------------------------------------------------------------------- 83 | uint32_t CRingBuffer::GetDataSize(void) const 84 | { 85 | if (Head=Size) return(0); 123 | return(Buffer[pos]); 124 | } 125 | //---------------------------------------------------------------------------------------------------- 126 | //задать позицию хвоста буфера 127 | //---------------------------------------------------------------------------------------------------- 128 | void CRingBuffer::SetTailPos(uint32_t pos) 129 | { 130 | if (pos>=Size) return; 131 | Tail=pos; 132 | } 133 | //---------------------------------------------------------------------------------------------------- 134 | //задать позицию головы буфера 135 | //---------------------------------------------------------------------------------------------------- 136 | void CRingBuffer::SetHeadPos(uint32_t pos) 137 | { 138 | if (pos>=Size) return; 139 | Head=pos; 140 | } 141 | 142 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/jcapistd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jcapistd.c 3 | * 4 | * Copyright (C) 1994-1996, Thomas G. Lane. 5 | * Modified 2013 by Guido Vollbeding. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file contains application interface code for the compression half 10 | * of the JPEG library. These are the "standard" API routines that are 11 | * used in the normal full-compression case. They are not used by a 12 | * transcoding-only application. Note that if an application links in 13 | * jpeg_start_compress, it will end up linking in the entire compressor. 14 | * We thus must separate this file from jcapimin.c to avoid linking the 15 | * whole compression library into a transcoder. 16 | */ 17 | 18 | #define JPEG_INTERNALS 19 | #include "jinclude.h" 20 | #include "jpeglib.h" 21 | 22 | 23 | /* 24 | * Compression initialization. 25 | * Before calling this, all parameters and a data destination must be set up. 26 | * 27 | * We require a write_all_tables parameter as a failsafe check when writing 28 | * multiple datastreams from the same compression object. Since prior runs 29 | * will have left all the tables marked sent_table=TRUE, a subsequent run 30 | * would emit an abbreviated stream (no tables) by default. This may be what 31 | * is wanted, but for safety's sake it should not be the default behavior: 32 | * programmers should have to make a deliberate choice to emit abbreviated 33 | * images. Therefore the documentation and examples should encourage people 34 | * to pass write_all_tables=TRUE; then it will take active thought to do the 35 | * wrong thing. 36 | */ 37 | 38 | GLOBAL(void) 39 | jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) 40 | { 41 | if (cinfo->global_state != CSTATE_START) 42 | ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 43 | 44 | if (write_all_tables) 45 | jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */ 46 | 47 | /* (Re)initialize error mgr and destination modules */ 48 | (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); 49 | (*cinfo->dest->init_destination) (cinfo); 50 | /* Perform master selection of active modules */ 51 | jinit_compress_master(cinfo); 52 | /* Set up for the first pass */ 53 | (*cinfo->master->prepare_for_pass) (cinfo); 54 | /* Ready for application to drive first pass through jpeg_write_scanlines 55 | * or jpeg_write_raw_data. 56 | */ 57 | cinfo->next_scanline = 0; 58 | cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING); 59 | } 60 | 61 | 62 | /* 63 | * Write some scanlines of data to the JPEG compressor. 64 | * 65 | * The return value will be the number of lines actually written. 66 | * This should be less than the supplied num_lines only in case that 67 | * the data destination module has requested suspension of the compressor, 68 | * or if more than image_height scanlines are passed in. 69 | * 70 | * Note: we warn about excess calls to jpeg_write_scanlines() since 71 | * this likely signals an application programmer error. However, 72 | * excess scanlines passed in the last valid call are *silently* ignored, 73 | * so that the application need not adjust num_lines for end-of-image 74 | * when using a multiple-scanline buffer. 75 | */ 76 | 77 | GLOBAL(JDIMENSION) 78 | jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, 79 | JDIMENSION num_lines) 80 | { 81 | JDIMENSION row_ctr, rows_left; 82 | 83 | if (cinfo->global_state != CSTATE_SCANNING) 84 | ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 85 | if (cinfo->next_scanline >= cinfo->image_height) 86 | WARNMS(cinfo, JWRN_TOO_MUCH_DATA); 87 | 88 | /* Call progress monitor hook if present */ 89 | if (cinfo->progress != NULL) { 90 | cinfo->progress->pass_counter = (long) cinfo->next_scanline; 91 | cinfo->progress->pass_limit = (long) cinfo->image_height; 92 | (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); 93 | } 94 | 95 | /* Give master control module another chance if this is first call to 96 | * jpeg_write_scanlines. This lets output of the frame/scan headers be 97 | * delayed so that application can write COM, etc, markers between 98 | * jpeg_start_compress and jpeg_write_scanlines. 99 | */ 100 | if (cinfo->master->call_pass_startup) 101 | (*cinfo->master->pass_startup) (cinfo); 102 | 103 | /* Ignore any extra scanlines at bottom of image. */ 104 | rows_left = cinfo->image_height - cinfo->next_scanline; 105 | if (num_lines > rows_left) 106 | num_lines = rows_left; 107 | 108 | row_ctr = 0; 109 | (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines); 110 | cinfo->next_scanline += row_ctr; 111 | return row_ctr; 112 | } 113 | 114 | 115 | /* 116 | * Alternate entry point to write raw data. 117 | * Processes exactly one iMCU row per call, unless suspended. 118 | */ 119 | 120 | GLOBAL(JDIMENSION) 121 | jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, 122 | JDIMENSION num_lines) 123 | { 124 | JDIMENSION lines_per_iMCU_row; 125 | 126 | if (cinfo->global_state != CSTATE_RAW_OK) 127 | ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); 128 | if (cinfo->next_scanline >= cinfo->image_height) { 129 | WARNMS(cinfo, JWRN_TOO_MUCH_DATA); 130 | return 0; 131 | } 132 | 133 | /* Call progress monitor hook if present */ 134 | if (cinfo->progress != NULL) { 135 | cinfo->progress->pass_counter = (long) cinfo->next_scanline; 136 | cinfo->progress->pass_limit = (long) cinfo->image_height; 137 | (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); 138 | } 139 | 140 | /* Give master control module another chance if this is first call to 141 | * jpeg_write_raw_data. This lets output of the frame/scan headers be 142 | * delayed so that application can write COM, etc, markers between 143 | * jpeg_start_compress and jpeg_write_raw_data. 144 | */ 145 | if (cinfo->master->call_pass_startup) 146 | (*cinfo->master->pass_startup) (cinfo); 147 | 148 | /* Verify that at least one iMCU row has been passed. */ 149 | lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size; 150 | if (num_lines < lines_per_iMCU_row) 151 | ERREXIT(cinfo, JERR_BUFFER_SIZE); 152 | 153 | /* Directly compress the row. */ 154 | if (! (*cinfo->coef->compress_data) (cinfo, data)) { 155 | /* If compressor did not consume the whole row, suspend processing. */ 156 | return 0; 157 | } 158 | 159 | /* OK, we processed one iMCU row. */ 160 | cinfo->next_scanline += lines_per_iMCU_row; 161 | return lines_per_iMCU_row; 162 | } 163 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/jfdctflt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jfdctflt.c 3 | * 4 | * Copyright (C) 1994-1996, Thomas G. Lane. 5 | * Modified 2003-2017 by Guido Vollbeding. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file contains a floating-point implementation of the 10 | * forward DCT (Discrete Cosine Transform). 11 | * 12 | * This implementation should be more accurate than either of the integer 13 | * DCT implementations. However, it may not give the same results on all 14 | * machines because of differences in roundoff behavior. Speed will depend 15 | * on the hardware's floating point capacity. 16 | * 17 | * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT 18 | * on each column. Direct algorithms are also available, but they are 19 | * much more complex and seem not to be any faster when reduced to code. 20 | * 21 | * This implementation is based on Arai, Agui, and Nakajima's algorithm for 22 | * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in 23 | * Japanese, but the algorithm is described in the Pennebaker & Mitchell 24 | * JPEG textbook (see REFERENCES section in file README). The following code 25 | * is based directly on figure 4-8 in P&M. 26 | * While an 8-point DCT cannot be done in less than 11 multiplies, it is 27 | * possible to arrange the computation so that many of the multiplies are 28 | * simple scalings of the final outputs. These multiplies can then be 29 | * folded into the multiplications or divisions by the JPEG quantization 30 | * table entries. The AA&N method leaves only 5 multiplies and 29 adds 31 | * to be done in the DCT itself. 32 | * The primary disadvantage of this method is that with a fixed-point 33 | * implementation, accuracy is lost due to imprecise representation of the 34 | * scaled quantization values. However, that problem does not arise if 35 | * we use floating point arithmetic. 36 | */ 37 | 38 | #define JPEG_INTERNALS 39 | #include "jinclude.h" 40 | #include "jpeglib.h" 41 | #include "jdct.h" /* Private declarations for DCT subsystem */ 42 | 43 | #ifdef DCT_FLOAT_SUPPORTED 44 | 45 | 46 | /* 47 | * This module is specialized to the case DCTSIZE = 8. 48 | */ 49 | 50 | #if DCTSIZE != 8 51 | Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */ 52 | #endif 53 | 54 | 55 | /* 56 | * Perform the forward DCT on one block of samples. 57 | * 58 | * cK represents cos(K*pi/16). 59 | */ 60 | 61 | GLOBAL(void) 62 | jpeg_fdct_float (FAST_FLOAT * data, JSAMPARRAY sample_data, JDIMENSION start_col) 63 | { 64 | FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; 65 | FAST_FLOAT tmp10, tmp11, tmp12, tmp13; 66 | FAST_FLOAT z1, z2, z3, z4, z5, z11, z13; 67 | FAST_FLOAT *dataptr; 68 | JSAMPROW elemptr; 69 | int ctr; 70 | 71 | /* Pass 1: process rows. */ 72 | 73 | dataptr = data; 74 | for (ctr = 0; ctr < DCTSIZE; ctr++) { 75 | elemptr = sample_data[ctr] + start_col; 76 | 77 | /* Load data into workspace */ 78 | tmp0 = (FAST_FLOAT) (GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7])); 79 | tmp7 = (FAST_FLOAT) (GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[7])); 80 | tmp1 = (FAST_FLOAT) (GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[6])); 81 | tmp6 = (FAST_FLOAT) (GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[6])); 82 | tmp2 = (FAST_FLOAT) (GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[5])); 83 | tmp5 = (FAST_FLOAT) (GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5])); 84 | tmp3 = (FAST_FLOAT) (GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[4])); 85 | tmp4 = (FAST_FLOAT) (GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4])); 86 | 87 | /* Even part */ 88 | 89 | tmp10 = tmp0 + tmp3; /* phase 2 */ 90 | tmp13 = tmp0 - tmp3; 91 | tmp11 = tmp1 + tmp2; 92 | tmp12 = tmp1 - tmp2; 93 | 94 | /* Apply unsigned->signed conversion. */ 95 | dataptr[0] = tmp10 + tmp11 - 8 * CENTERJSAMPLE; /* phase 3 */ 96 | dataptr[4] = tmp10 - tmp11; 97 | 98 | z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ 99 | dataptr[2] = tmp13 + z1; /* phase 5 */ 100 | dataptr[6] = tmp13 - z1; 101 | 102 | /* Odd part */ 103 | 104 | tmp10 = tmp4 + tmp5; /* phase 2 */ 105 | tmp11 = tmp5 + tmp6; 106 | tmp12 = tmp6 + tmp7; 107 | 108 | /* The rotator is modified from fig 4-8 to avoid extra negations. */ 109 | z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ 110 | z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ 111 | z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ 112 | z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ 113 | 114 | z11 = tmp7 + z3; /* phase 5 */ 115 | z13 = tmp7 - z3; 116 | 117 | dataptr[5] = z13 + z2; /* phase 6 */ 118 | dataptr[3] = z13 - z2; 119 | dataptr[1] = z11 + z4; 120 | dataptr[7] = z11 - z4; 121 | 122 | dataptr += DCTSIZE; /* advance pointer to next row */ 123 | } 124 | 125 | /* Pass 2: process columns. */ 126 | 127 | dataptr = data; 128 | for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { 129 | tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; 130 | tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; 131 | tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; 132 | tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; 133 | tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; 134 | tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; 135 | tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; 136 | tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; 137 | 138 | /* Even part */ 139 | 140 | tmp10 = tmp0 + tmp3; /* phase 2 */ 141 | tmp13 = tmp0 - tmp3; 142 | tmp11 = tmp1 + tmp2; 143 | tmp12 = tmp1 - tmp2; 144 | 145 | dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ 146 | dataptr[DCTSIZE*4] = tmp10 - tmp11; 147 | 148 | z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ 149 | dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ 150 | dataptr[DCTSIZE*6] = tmp13 - z1; 151 | 152 | /* Odd part */ 153 | 154 | tmp10 = tmp4 + tmp5; /* phase 2 */ 155 | tmp11 = tmp5 + tmp6; 156 | tmp12 = tmp6 + tmp7; 157 | 158 | /* The rotator is modified from fig 4-8 to avoid extra negations. */ 159 | z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ 160 | z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ 161 | z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ 162 | z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ 163 | 164 | z11 = tmp7 + z3; /* phase 5 */ 165 | z13 = tmp7 - z3; 166 | 167 | dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ 168 | dataptr[DCTSIZE*3] = z13 - z2; 169 | dataptr[DCTSIZE*1] = z11 + z4; 170 | dataptr[DCTSIZE*7] = z11 - z4; 171 | 172 | dataptr++; /* advance pointer to next column */ 173 | } 174 | } 175 | 176 | #endif /* DCT_FLOAT_SUPPORTED */ 177 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/cdjpeg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * cdjpeg.h 3 | * 4 | * Copyright (C) 1994-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains common declarations for the sample applications 9 | * cjpeg and djpeg. It is NOT used by the core JPEG library. 10 | */ 11 | 12 | #define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */ 13 | #define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */ 14 | #include "jinclude.h" 15 | #include "jpeglib.h" 16 | #include "jerror.h" /* get library error codes too */ 17 | #include "cderror.h" /* get application-specific error codes */ 18 | 19 | 20 | /* 21 | * Object interface for cjpeg's source file decoding modules 22 | */ 23 | 24 | typedef struct cjpeg_source_struct * cjpeg_source_ptr; 25 | 26 | struct cjpeg_source_struct { 27 | JMETHOD(void, start_input, (j_compress_ptr cinfo, 28 | cjpeg_source_ptr sinfo)); 29 | JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo, 30 | cjpeg_source_ptr sinfo)); 31 | JMETHOD(void, finish_input, (j_compress_ptr cinfo, 32 | cjpeg_source_ptr sinfo)); 33 | 34 | FILE *input_file; 35 | 36 | JSAMPARRAY buffer; 37 | JDIMENSION buffer_height; 38 | }; 39 | 40 | 41 | /* 42 | * Object interface for djpeg's output file encoding modules 43 | */ 44 | 45 | typedef struct djpeg_dest_struct * djpeg_dest_ptr; 46 | 47 | struct djpeg_dest_struct { 48 | /* start_output is called after jpeg_start_decompress finishes. 49 | * The color map will be ready at this time, if one is needed. 50 | */ 51 | JMETHOD(void, start_output, (j_decompress_ptr cinfo, 52 | djpeg_dest_ptr dinfo)); 53 | /* Emit the specified number of pixel rows from the buffer. */ 54 | JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo, 55 | djpeg_dest_ptr dinfo, 56 | JDIMENSION rows_supplied)); 57 | /* Finish up at the end of the image. */ 58 | JMETHOD(void, finish_output, (j_decompress_ptr cinfo, 59 | djpeg_dest_ptr dinfo)); 60 | 61 | /* Target file spec; filled in by djpeg.c after object is created. */ 62 | FILE * output_file; 63 | 64 | /* Output pixel-row buffer. Created by module init or start_output. 65 | * Width is cinfo->output_width * cinfo->output_components; 66 | * height is buffer_height. 67 | */ 68 | JSAMPARRAY buffer; 69 | JDIMENSION buffer_height; 70 | }; 71 | 72 | 73 | /* 74 | * cjpeg/djpeg may need to perform extra passes to convert to or from 75 | * the source/destination file format. The JPEG library does not know 76 | * about these passes, but we'd like them to be counted by the progress 77 | * monitor. We use an expanded progress monitor object to hold the 78 | * additional pass count. 79 | */ 80 | 81 | struct cdjpeg_progress_mgr { 82 | struct jpeg_progress_mgr pub; /* fields known to JPEG library */ 83 | int completed_extra_passes; /* extra passes completed */ 84 | int total_extra_passes; /* total extra */ 85 | /* last printed percentage stored here to avoid multiple printouts */ 86 | int percent_done; 87 | }; 88 | 89 | typedef struct cdjpeg_progress_mgr * cd_progress_ptr; 90 | 91 | 92 | /* Short forms of external names for systems with brain-damaged linkers. */ 93 | 94 | #ifdef NEED_SHORT_EXTERNAL_NAMES 95 | #define jinit_read_bmp jIRdBMP 96 | #define jinit_write_bmp jIWrBMP 97 | #define jinit_read_gif jIRdGIF 98 | #define jinit_write_gif jIWrGIF 99 | #define jinit_read_ppm jIRdPPM 100 | #define jinit_write_ppm jIWrPPM 101 | #define jinit_read_rle jIRdRLE 102 | #define jinit_write_rle jIWrRLE 103 | #define jinit_read_targa jIRdTarga 104 | #define jinit_write_targa jIWrTarga 105 | #define read_quant_tables RdQTables 106 | #define read_scan_script RdScnScript 107 | #define set_quality_ratings SetQRates 108 | #define set_quant_slots SetQSlots 109 | #define set_sample_factors SetSFacts 110 | #define read_color_map RdCMap 111 | #define enable_signal_catcher EnSigCatcher 112 | #define start_progress_monitor StProgMon 113 | #define end_progress_monitor EnProgMon 114 | #define read_stdin RdStdin 115 | #define write_stdout WrStdout 116 | #endif /* NEED_SHORT_EXTERNAL_NAMES */ 117 | 118 | /* Module selection routines for I/O modules. */ 119 | 120 | EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo)); 121 | EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo, 122 | boolean is_os2)); 123 | EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo)); 124 | EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo)); 125 | EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo)); 126 | EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo)); 127 | EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo)); 128 | EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo)); 129 | EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo)); 130 | EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo)); 131 | 132 | /* cjpeg support routines (in rdswitch.c) */ 133 | 134 | EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename, 135 | boolean force_baseline)); 136 | EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename)); 137 | EXTERN(boolean) set_quality_ratings JPP((j_compress_ptr cinfo, char *arg, 138 | boolean force_baseline)); 139 | EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg)); 140 | EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg)); 141 | 142 | /* djpeg support routines (in rdcolmap.c) */ 143 | 144 | EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile)); 145 | 146 | /* common support routines (in cdjpeg.c) */ 147 | 148 | EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo)); 149 | EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo, 150 | cd_progress_ptr progress)); 151 | EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo)); 152 | EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars)); 153 | EXTERN(FILE *) read_stdin JPP((void)); 154 | EXTERN(FILE *) write_stdout JPP((void)); 155 | 156 | /* miscellaneous useful macros */ 157 | 158 | #ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */ 159 | #define READ_BINARY "r" 160 | #define WRITE_BINARY "w" 161 | #else 162 | #ifdef VMS /* VMS is very nonstandard */ 163 | #define READ_BINARY "rb", "ctx=stm" 164 | #define WRITE_BINARY "wb", "ctx=stm" 165 | #else /* standard ANSI-compliant case */ 166 | #define READ_BINARY "rb" 167 | #define WRITE_BINARY "wb" 168 | #endif 169 | #endif 170 | 171 | #ifndef EXIT_FAILURE /* define exit() codes if not provided */ 172 | #define EXIT_FAILURE 1 173 | #endif 174 | #ifndef EXIT_SUCCESS 175 | #ifdef VMS 176 | #define EXIT_SUCCESS 1 /* VMS is very nonstandard */ 177 | #else 178 | #define EXIT_SUCCESS 0 179 | #endif 180 | #endif 181 | #ifndef EXIT_WARNING 182 | #ifdef VMS 183 | #define EXIT_WARNING 1 /* VMS is very nonstandard */ 184 | #else 185 | #define EXIT_WARNING 2 186 | #endif 187 | #endif 188 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/jutils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jutils.c 3 | * 4 | * Copyright (C) 1991-1996, Thomas G. Lane. 5 | * Modified 2009-2011 by Guido Vollbeding. 6 | * This file is part of the Independent JPEG Group's software. 7 | * For conditions of distribution and use, see the accompanying README file. 8 | * 9 | * This file contains tables and miscellaneous utility routines needed 10 | * for both compression and decompression. 11 | * Note we prefix all global names with "j" to minimize conflicts with 12 | * a surrounding application. 13 | */ 14 | 15 | #define JPEG_INTERNALS 16 | #include "jinclude.h" 17 | #include "jpeglib.h" 18 | 19 | 20 | /* 21 | * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element 22 | * of a DCT block read in natural order (left to right, top to bottom). 23 | */ 24 | 25 | #if 0 /* This table is not actually needed in v6a */ 26 | 27 | const int jpeg_zigzag_order[DCTSIZE2] = { 28 | 0, 1, 5, 6, 14, 15, 27, 28, 29 | 2, 4, 7, 13, 16, 26, 29, 42, 30 | 3, 8, 12, 17, 25, 30, 41, 43, 31 | 9, 11, 18, 24, 31, 40, 44, 53, 32 | 10, 19, 23, 32, 39, 45, 52, 54, 33 | 20, 22, 33, 38, 46, 51, 55, 60, 34 | 21, 34, 37, 47, 50, 56, 59, 61, 35 | 35, 36, 48, 49, 57, 58, 62, 63 36 | }; 37 | 38 | #endif 39 | 40 | /* 41 | * jpeg_natural_order[i] is the natural-order position of the i'th element 42 | * of zigzag order. 43 | * 44 | * When reading corrupted data, the Huffman decoders could attempt 45 | * to reference an entry beyond the end of this array (if the decoded 46 | * zero run length reaches past the end of the block). To prevent 47 | * wild stores without adding an inner-loop test, we put some extra 48 | * "63"s after the real entries. This will cause the extra coefficient 49 | * to be stored in location 63 of the block, not somewhere random. 50 | * The worst case would be a run-length of 15, which means we need 16 51 | * fake entries. 52 | */ 53 | 54 | const int jpeg_natural_order[DCTSIZE2+16] = { 55 | 0, 1, 8, 16, 9, 2, 3, 10, 56 | 17, 24, 32, 25, 18, 11, 4, 5, 57 | 12, 19, 26, 33, 40, 48, 41, 34, 58 | 27, 20, 13, 6, 7, 14, 21, 28, 59 | 35, 42, 49, 56, 57, 50, 43, 36, 60 | 29, 22, 15, 23, 30, 37, 44, 51, 61 | 58, 59, 52, 45, 38, 31, 39, 46, 62 | 53, 60, 61, 54, 47, 55, 62, 63, 63 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ 64 | 63, 63, 63, 63, 63, 63, 63, 63 65 | }; 66 | 67 | const int jpeg_natural_order7[7*7+16] = { 68 | 0, 1, 8, 16, 9, 2, 3, 10, 69 | 17, 24, 32, 25, 18, 11, 4, 5, 70 | 12, 19, 26, 33, 40, 48, 41, 34, 71 | 27, 20, 13, 6, 14, 21, 28, 35, 72 | 42, 49, 50, 43, 36, 29, 22, 30, 73 | 37, 44, 51, 52, 45, 38, 46, 53, 74 | 54, 75 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ 76 | 63, 63, 63, 63, 63, 63, 63, 63 77 | }; 78 | 79 | const int jpeg_natural_order6[6*6+16] = { 80 | 0, 1, 8, 16, 9, 2, 3, 10, 81 | 17, 24, 32, 25, 18, 11, 4, 5, 82 | 12, 19, 26, 33, 40, 41, 34, 27, 83 | 20, 13, 21, 28, 35, 42, 43, 36, 84 | 29, 37, 44, 45, 85 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ 86 | 63, 63, 63, 63, 63, 63, 63, 63 87 | }; 88 | 89 | const int jpeg_natural_order5[5*5+16] = { 90 | 0, 1, 8, 16, 9, 2, 3, 10, 91 | 17, 24, 32, 25, 18, 11, 4, 12, 92 | 19, 26, 33, 34, 27, 20, 28, 35, 93 | 36, 94 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ 95 | 63, 63, 63, 63, 63, 63, 63, 63 96 | }; 97 | 98 | const int jpeg_natural_order4[4*4+16] = { 99 | 0, 1, 8, 16, 9, 2, 3, 10, 100 | 17, 24, 25, 18, 11, 19, 26, 27, 101 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ 102 | 63, 63, 63, 63, 63, 63, 63, 63 103 | }; 104 | 105 | const int jpeg_natural_order3[3*3+16] = { 106 | 0, 1, 8, 16, 9, 2, 10, 17, 107 | 18, 108 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ 109 | 63, 63, 63, 63, 63, 63, 63, 63 110 | }; 111 | 112 | const int jpeg_natural_order2[2*2+16] = { 113 | 0, 1, 8, 9, 114 | 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ 115 | 63, 63, 63, 63, 63, 63, 63, 63 116 | }; 117 | 118 | 119 | /* 120 | * Arithmetic utilities 121 | */ 122 | 123 | GLOBAL(long) 124 | jdiv_round_up (long a, long b) 125 | /* Compute a/b rounded up to next integer, ie, ceil(a/b) */ 126 | /* Assumes a >= 0, b > 0 */ 127 | { 128 | return (a + b - 1L) / b; 129 | } 130 | 131 | 132 | GLOBAL(long) 133 | jround_up (long a, long b) 134 | /* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ 135 | /* Assumes a >= 0, b > 0 */ 136 | { 137 | a += b - 1L; 138 | return a - (a % b); 139 | } 140 | 141 | 142 | /* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays 143 | * and coefficient-block arrays. This won't work on 80x86 because the arrays 144 | * are FAR and we're assuming a small-pointer memory model. However, some 145 | * DOS compilers provide far-pointer versions of memcpy() and memset() even 146 | * in the small-model libraries. These will be used if USE_FMEM is defined. 147 | * Otherwise, the routines below do it the hard way. (The performance cost 148 | * is not all that great, because these routines aren't very heavily used.) 149 | */ 150 | 151 | #ifndef NEED_FAR_POINTERS /* normal case, same as regular macro */ 152 | #define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) 153 | #else /* 80x86 case, define if we can */ 154 | #ifdef USE_FMEM 155 | #define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) 156 | #else 157 | /* This function is for use by the FMEMZERO macro defined in jpegint.h. 158 | * Do not call this function directly, use the FMEMZERO macro instead. 159 | */ 160 | GLOBAL(void) 161 | jzero_far (void FAR * target, size_t bytestozero) 162 | /* Zero out a chunk of FAR memory. */ 163 | /* This might be sample-array data, block-array data, or alloc_large data. */ 164 | { 165 | register char FAR * ptr = (char FAR *) target; 166 | register size_t count; 167 | 168 | for (count = bytestozero; count > 0; count--) { 169 | *ptr++ = 0; 170 | } 171 | } 172 | #endif 173 | #endif 174 | 175 | 176 | GLOBAL(void) 177 | jcopy_sample_rows (JSAMPARRAY input_array, int source_row, 178 | JSAMPARRAY output_array, int dest_row, 179 | int num_rows, JDIMENSION num_cols) 180 | /* Copy some rows of samples from one place to another. 181 | * num_rows rows are copied from input_array[source_row++] 182 | * to output_array[dest_row++]; these areas may overlap for duplication. 183 | * The source and destination arrays must be at least as wide as num_cols. 184 | */ 185 | { 186 | register JSAMPROW inptr, outptr; 187 | #ifdef FMEMCOPY 188 | register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); 189 | #else 190 | register JDIMENSION count; 191 | #endif 192 | register int row; 193 | 194 | input_array += source_row; 195 | output_array += dest_row; 196 | 197 | for (row = num_rows; row > 0; row--) { 198 | inptr = *input_array++; 199 | outptr = *output_array++; 200 | #ifdef FMEMCOPY 201 | FMEMCOPY(outptr, inptr, count); 202 | #else 203 | for (count = num_cols; count > 0; count--) 204 | *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ 205 | #endif 206 | } 207 | } 208 | 209 | 210 | GLOBAL(void) 211 | jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, 212 | JDIMENSION num_blocks) 213 | /* Copy a row of coefficient blocks from one place to another. */ 214 | { 215 | #ifdef FMEMCOPY 216 | FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); 217 | #else 218 | register JCOEFPTR inptr, outptr; 219 | register long count; 220 | 221 | inptr = (JCOEFPTR) input_row; 222 | outptr = (JCOEFPTR) output_row; 223 | for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { 224 | *outptr++ = *inptr++; 225 | } 226 | #endif 227 | } 228 | -------------------------------------------------------------------------------- /FlirOneControl/cflironedriver.cpp: -------------------------------------------------------------------------------- 1 | //**************************************************************************************************** 2 | //подключаемые библиотеки 3 | //**************************************************************************************************** 4 | #include "cflironedriver.h" 5 | #include "clog.h" 6 | 7 | #include 8 | #include 9 | 10 | 11 | //**************************************************************************************************** 12 | //глобальные переменные 13 | //**************************************************************************************************** 14 | 15 | //**************************************************************************************************** 16 | //константы 17 | //**************************************************************************************************** 18 | 19 | //**************************************************************************************************** 20 | //макроопределения 21 | //**************************************************************************************************** 22 | 23 | //**************************************************************************************************** 24 | //конструктор и деструктор 25 | //**************************************************************************************************** 26 | 27 | //---------------------------------------------------------------------------------------------------- 28 | //конструктор 29 | //---------------------------------------------------------------------------------------------------- 30 | CFlirOneDriver::CFlirOneDriver(void) 31 | { 32 | USBDeviceHandle=NULL; 33 | Ready=false; 34 | } 35 | //---------------------------------------------------------------------------------------------------- 36 | //деструктор 37 | //---------------------------------------------------------------------------------------------------- 38 | CFlirOneDriver::~CFlirOneDriver() 39 | { 40 | Close(); 41 | } 42 | 43 | //**************************************************************************************************** 44 | //закрытые функции 45 | //**************************************************************************************************** 46 | 47 | //---------------------------------------------------------------------------------------------------- 48 | //инициализация Flir One 49 | //---------------------------------------------------------------------------------------------------- 50 | bool CFlirOneDriver::InitFlirOne(void) 51 | { 52 | uint8_t data[2]={0,0}; 53 | //останавливаем интерфейс 2 (FRAME) 54 | if (libusb_control_transfer(USBDeviceHandle,1,0x0b,0,2,data,0,100)<0) 55 | { 56 | CLog::GetPtr()->AddLog("[ОШИБКА] Ошибка остановки интерфейса 2!\r\n"); 57 | return(false);//ошибка настройки 58 | } 59 | data[0]=0; 60 | data[1]=0; 61 | //останавливаем интерфейс 1 (FILEIO) 62 | if (libusb_control_transfer(USBDeviceHandle,1,0x0b,0,1,data,0,100)<0) 63 | { 64 | CLog::GetPtr()->AddLog("[ОШИБКА] Ошибка остановки интерфейса 1!\r\n"); 65 | return(false);//ошибка настройки 66 | } 67 | data[0]=0; 68 | data[1]=0; 69 | //запускаем интерфейс 1 (FILEIO) 70 | if (libusb_control_transfer(USBDeviceHandle,1,0x0b,1,1,data,0,100)<0) 71 | { 72 | CLog::GetPtr()->AddLog("[ОШИБКА] Ошибка включения интерфейса 1!\r\n"); 73 | return(false);//ошибка настройки 74 | } 75 | //запускаем интерфейс 2 (FRAME) 76 | data[0]=0; 77 | data[1]=0; 78 | if (libusb_control_transfer(USBDeviceHandle,1,0x0b,1,2,data,0,200)<0) 79 | { 80 | CLog::GetPtr()->AddLog("[ОШИБКА] Ошибка настройки передачи интерфейса frame!\r\n"); 81 | return(false);//ошибка настройки 82 | } 83 | return(true); 84 | } 85 | 86 | //---------------------------------------------------------------------------------------------------- 87 | //подключение к Flir One 88 | //---------------------------------------------------------------------------------------------------- 89 | bool CFlirOneDriver::ConnectToFlirOne(void) 90 | { 91 | if (libusb_init(NULL)<0) 92 | { 93 | CLog::GetPtr()->AddLog("[ОШИБКА] Не удалось инициализировать LibUsb!\r\n"); 94 | return(false); 95 | } 96 | //ищем Flir One Gen 2 97 | USBDeviceHandle=libusb_open_device_with_vid_pid(NULL,VENDOR_ID,PRODUCT_ID); 98 | if (USBDeviceHandle==NULL) 99 | { 100 | CLog::GetPtr()->AddLog("[ОШИБКА] Тепловизор Flir One Gen 2 не найден!\r\n"); 101 | return(false); 102 | } 103 | CLog::GetPtr()->AddLog("Тепловизор Flir One Gen 2 найден!\r\n"); 104 | //настраиваем конфигурацию устройства 105 | if (libusb_set_configuration(USBDeviceHandle,3)<0) 106 | { 107 | CLog::GetPtr()->CLog::GetPtr()->AddLog("[ОШИБКА] Ошибка настройки конфигурации устройства!\r\n"); 108 | return(false); 109 | } 110 | if (libusb_claim_interface(USBDeviceHandle,0)<0) 111 | { 112 | CLog::GetPtr()->AddLog("[ОШИБКА] Ошибка включения интерфейса 0!\r\n"); 113 | return(false); 114 | } 115 | if (libusb_claim_interface(USBDeviceHandle,1)<0) 116 | { 117 | CLog::GetPtr()->AddLog("[ОШИБКА] Ошибка включения интерфейса 1!\r\n"); 118 | return(false); 119 | } 120 | if (libusb_claim_interface(USBDeviceHandle,2)<0) 121 | { 122 | CLog::GetPtr()->AddLog("[ОШИБКА] Ошибка включения интерфейса 2!\r\n"); 123 | return(false); 124 | } 125 | CLog::GetPtr()->AddLog("Устройство успешно подключено.\r\n"); 126 | return(true); 127 | } 128 | 129 | 130 | //**************************************************************************************************** 131 | //открытые функции 132 | //**************************************************************************************************** 133 | 134 | 135 | //---------------------------------------------------------------------------------------------------- 136 | //чтение данных из устройств 137 | //---------------------------------------------------------------------------------------------------- 138 | bool CFlirOneDriver::ReadStream(uint8_t* ptr,uint32_t &size) 139 | { 140 | if (Ready==false) return(false); 141 | int readen; 142 | long ret=libusb_bulk_transfer(USBDeviceHandle,0x85,ptr,size,&readen,100); 143 | size=readen; 144 | if (ret<0) 145 | { 146 | size=0; 147 | //printf("Error! %s\r\n",libusb_error_name(ret)); 148 | CLog::GetPtr()->AddLog("[ОШИБКА] Ошибка приёма данных frame! "); 149 | } 150 | static const size_t BUFFER_SIZE=1024; 151 | static uint8_t buffer[BUFFER_SIZE]; 152 | ret=libusb_bulk_transfer(USBDeviceHandle,0x81,buffer,BUFFER_SIZE,&readen,10); 153 | ret=libusb_bulk_transfer(USBDeviceHandle,0x83,buffer,BUFFER_SIZE,&readen,10); 154 | if (strcmp(libusb_error_name(ret),"LIBUSB_ERROR_NO_DEVICE")==0) 155 | { 156 | Close(); 157 | CLog::GetPtr()->AddLog("[ОШИБКА] Ошибка LIBUSB_ERROR_NO_DEVICE!\r\n"); 158 | return(false); 159 | } 160 | return(true); 161 | } 162 | 163 | 164 | //---------------------------------------------------------------------------------------------------- 165 | //подключиться к устройству 166 | //---------------------------------------------------------------------------------------------------- 167 | bool CFlirOneDriver::Open(void) 168 | { 169 | Close(); 170 | if (ConnectToFlirOne()==false) 171 | { 172 | Close(); 173 | return(false); 174 | } 175 | if (InitFlirOne()==false) 176 | { 177 | Close(); 178 | return(false); 179 | } 180 | Ready=true; 181 | return(true); 182 | } 183 | //---------------------------------------------------------------------------------------------------- 184 | //отключиться от устройства 185 | //---------------------------------------------------------------------------------------------------- 186 | void CFlirOneDriver::Close(void) 187 | { 188 | if (USBDeviceHandle!=NULL) 189 | { 190 | CLog::GetPtr()->AddLog("Устройство отключено.\r\n"); 191 | libusb_reset_device(USBDeviceHandle); 192 | libusb_close(USBDeviceHandle); 193 | libusb_exit(NULL); 194 | } 195 | Ready=false; 196 | USBDeviceHandle=NULL; 197 | } 198 | -------------------------------------------------------------------------------- /FlirOneControl/cmainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef C_MAIN_WINDOW_H 2 | #define C_MAIN_WINDOW_H 3 | 4 | //**************************************************************************************************** 5 | //Класс главного окна программы 6 | //**************************************************************************************************** 7 | 8 | //**************************************************************************************************** 9 | //подключаемые библиотеки 10 | //**************************************************************************************************** 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "iimage.h" 18 | #include "cflironecontrol.h" 19 | #include "clabel_imagearea.h" 20 | #include "cgraphics.h" 21 | 22 | //**************************************************************************************************** 23 | //пространства имён 24 | //**************************************************************************************************** 25 | namespace Ui 26 | { 27 | class CMainWindow; 28 | } 29 | 30 | //**************************************************************************************************** 31 | //макроопределения 32 | //**************************************************************************************************** 33 | 34 | //**************************************************************************************************** 35 | //константы 36 | //**************************************************************************************************** 37 | 38 | //**************************************************************************************************** 39 | //предварительные объявления 40 | //**************************************************************************************************** 41 | 42 | //**************************************************************************************************** 43 | //Класс главного окна программы 44 | //**************************************************************************************************** 45 | class CMainWindow:public QMainWindow 46 | { 47 | Q_OBJECT 48 | private: 49 | //-перечисления--------------------------------------------------------------------------------------- 50 | //-структуры------------------------------------------------------------------------------------------ 51 | //-константы------------------------------------------------------------------------------------------ 52 | static const uint32_t TIMER_INTERVAL_MS=100;//интервал срабатывания таймера, мс 53 | static const int32_t FRAME_SIZE=3;//размер области измерения температуры 54 | static const int32_t IMAGE_VIEW_WIDTH=(CFlirOneReceiver::IMAGE_WIDTH+4+CGraphics::FONT_WIDTH*7); 55 | static const int32_t IMAGE_VIEW_HEIGHT=(CFlirOneReceiver::IMAGE_HEIGHT); 56 | static const size_t PATH_STRING_BUFFER_SIZE=1024;//размер строки для пути 57 | static const size_t STRING_BUFFER_SIZE=255;//размер строки 58 | 59 | static const uint32_t COLOR_WHITE=0xFFFFFFFF;//белый цвет 60 | static const uint32_t COLOR_BLACK=0xFF000000;//чёрный цвет 61 | 62 | static const uint32_t ALARM_MAX_TEMPER_COUNTER_MAX_VALUE=5;//максимальное значение количества кадров с температурой выше маемимума до срабатывания сигнала 63 | static const uint32_t ALARM_MIN_TEMPER_COUNTER_MAX_VALUE=5;//максимальное значение количества кадров с температурой ниже минимума до срабатывания сигнала 64 | private: 65 | //-переменные----------------------------------------------------------------------------------------- 66 | Ui::CMainWindow *ui;//пользовательский интерфейс 67 | CFlirOneControl cFlirOneControl;//класс управления тепловизором Flir One 68 | int32_t TimerId;//идентификатор таймера 69 | 70 | uint32_t AlarmMaxTemperCounter;//счётчик количества кадров с температурой выше максимума до срабатывания сигнала 71 | uint32_t AlarmMinTemperCounter;//счётчик количества кадров в температурой ниже минимума до срабатывания сигнала 72 | 73 | CLabel_ImageArea *cLabel_ImageArea_ThermalImage_Ptr;//тепловое изображение 74 | CLabel_ImageArea *cLabel_ImageArea_VideoImage_Ptr;//видео 75 | 76 | std::vector ViewImage;//изображение, выводимое на экран 77 | std::vector SaveViewImage;//изображение, сохраняемое в файл (если сохранается полная картинка со шкалой) 78 | 79 | std::vector ColorImage;//раскрашенное изображение 80 | std::vector ThermalImage;//тепловое изображение 81 | std::vector VideoImage;//изображение с видеокамеры 82 | std::vector TemperatureImage;//температурное изображение 83 | 84 | uint32_t LastReceivedFrameIndex;//индекс последнего принятого изображения 85 | 86 | CGraphics cGraphics;//класс для рисования на изображении 87 | 88 | std::vector vector_PaletteFileName;//список палитр 89 | 90 | IImage *iImage_VideoPtr;//выводимый на экран кадр изображения с видеокамеры 91 | IImage *iImage_ViewPtr;//выводимое на экран изображение 92 | 93 | //параметры для расчёта температуры 94 | double PlanckR1; 95 | double PlanckB; 96 | double PlanckF; 97 | double PlanckO; 98 | double PlanckR2; 99 | 100 | double TempReflected;//температура болометров 101 | double Emissivity;//коэффициент излучения 102 | 103 | bool SaveAllFrame;//сохранять ли все кадры 104 | bool SaveImageNoScale;//сохранять без шкалы 105 | bool SaveImageCross;//рисовать перекрестье 106 | bool SaveRAW;//сохранять RAW 107 | bool SaveVideo;//сохранять картинку с видеокамеры 108 | bool ShowVideo;//показывать видео 109 | 110 | public: 111 | //-конструктор---------------------------------------------------------------------------------------- 112 | explicit CMainWindow(QWidget *parent=0); 113 | //-деструктор----------------------------------------------------------------------------------------- 114 | ~CMainWindow(); 115 | public: 116 | //-открытые функции----------------------------------------------------------------------------------- 117 | private: 118 | //-закрытые функции----------------------------------------------------------------------------------- 119 | void timerEvent(QTimerEvent *qTimerEvent_Ptr);//обработчик таймера 120 | void NewFrame(void);//новый кадр 121 | bool MinTemperControl(float t);//контроль минимальной температуры 122 | bool MaxTemperControl(float t);//контроль максимальной температуры 123 | void FindPalette(void);//поиск палитр 124 | void ChangeState(bool &state,QWidget *qWidget_Ptr);//смена состояния кнопки и значения флага 125 | void SetState(bool &state,QWidget *qWidget_Ptr,bool set_state);//задать состояние кнопки и флага 126 | bool GetTemperature(uint16_t raw14,double &value);//вычислить температуру 127 | void SaveThermalImage(void);//сохранить тепловое изображение 128 | void SaveColorImage(void);//сохранить раскрашенное изображение 129 | void SaveVideoImage(void);//сохранить кадр с видеокамеры 130 | void ApplyLanguage(void);//применить выбранный язык 131 | private slots: 132 | //-закрытые слоты------------------------------------------------------------------------------------- 133 | void on_pushButton_ApplyPalette_clicked();//нажата кнопка "Применить палитру" 134 | void on_pushButton_SaveVideo_clicked();//нажата кнопка "Сохранять кадры с видеокамеры" 135 | void on_pushButton_SaveImageCross_clicked();//нажата кнопка "Рисовать перекрестье" 136 | void on_pushButton_SaveImageNoScale_clicked();//нажата кнопка "Сохранять изображение без шкалы" 137 | void on_pushButton_SaveRAW_clicked();//нажата кнопка "Сохранять файл RAW" 138 | void on_pushButton_ShowVideo_clicked();//нажата кнопка "Показывать видео" 139 | void on_pushButton_SaveAllFrame_clicked();//нажата кнопка "Сохранять все кадры" 140 | void on_pushButton_SaveFrame_clicked();//нажата кнопка "Сохранить один кадр" 141 | void on_comboBox_Language_currentIndexChanged(const QString &arg1);//изменился выбор языкаS 142 | }; 143 | 144 | 145 | #endif 146 | -------------------------------------------------------------------------------- /FlirOneControl/libjpeg/rdcolmap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rdcolmap.c 3 | * 4 | * Copyright (C) 1994-1996, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file implements djpeg's "-map file" switch. It reads a source image 9 | * and constructs a colormap to be supplied to the JPEG decompressor. 10 | * 11 | * Currently, these file formats are supported for the map file: 12 | * GIF: the contents of the GIF's global colormap are used. 13 | * PPM (either text or raw flavor): the entire file is read and 14 | * each unique pixel value is entered in the map. 15 | * Note that reading a large PPM file will be horrendously slow. 16 | * Typically, a PPM-format map file should contain just one pixel 17 | * of each desired color. Such a file can be extracted from an 18 | * ordinary image PPM file with ppmtomap(1). 19 | * 20 | * Rescaling a PPM that has a maxval unequal to MAXJSAMPLE is not 21 | * currently implemented. 22 | */ 23 | 24 | #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ 25 | 26 | #ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */ 27 | 28 | /* Portions of this code are based on the PBMPLUS library, which is: 29 | ** 30 | ** Copyright (C) 1988 by Jef Poskanzer. 31 | ** 32 | ** Permission to use, copy, modify, and distribute this software and its 33 | ** documentation for any purpose and without fee is hereby granted, provided 34 | ** that the above copyright notice appear in all copies and that both that 35 | ** copyright notice and this permission notice appear in supporting 36 | ** documentation. This software is provided "as is" without express or 37 | ** implied warranty. 38 | */ 39 | 40 | 41 | /* 42 | * Add a (potentially) new color to the color map. 43 | */ 44 | 45 | LOCAL(void) 46 | add_map_entry (j_decompress_ptr cinfo, int R, int G, int B) 47 | { 48 | JSAMPROW colormap0 = cinfo->colormap[0]; 49 | JSAMPROW colormap1 = cinfo->colormap[1]; 50 | JSAMPROW colormap2 = cinfo->colormap[2]; 51 | int ncolors = cinfo->actual_number_of_colors; 52 | int index; 53 | 54 | /* Check for duplicate color. */ 55 | for (index = 0; index < ncolors; index++) { 56 | if (GETJSAMPLE(colormap0[index]) == R && 57 | GETJSAMPLE(colormap1[index]) == G && 58 | GETJSAMPLE(colormap2[index]) == B) 59 | return; /* color is already in map */ 60 | } 61 | 62 | /* Check for map overflow. */ 63 | if (ncolors >= (MAXJSAMPLE+1)) 64 | ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, (MAXJSAMPLE+1)); 65 | 66 | /* OK, add color to map. */ 67 | colormap0[ncolors] = (JSAMPLE) R; 68 | colormap1[ncolors] = (JSAMPLE) G; 69 | colormap2[ncolors] = (JSAMPLE) B; 70 | cinfo->actual_number_of_colors++; 71 | } 72 | 73 | 74 | /* 75 | * Extract color map from a GIF file. 76 | */ 77 | 78 | LOCAL(void) 79 | read_gif_map (j_decompress_ptr cinfo, FILE * infile) 80 | { 81 | int header[13]; 82 | int i, colormaplen; 83 | int R, G, B; 84 | 85 | /* Initial 'G' has already been read by read_color_map */ 86 | /* Read the rest of the GIF header and logical screen descriptor */ 87 | for (i = 1; i < 13; i++) { 88 | if ((header[i] = getc(infile)) == EOF) 89 | ERREXIT(cinfo, JERR_BAD_CMAP_FILE); 90 | } 91 | 92 | /* Verify GIF Header */ 93 | if (header[1] != 'I' || header[2] != 'F') 94 | ERREXIT(cinfo, JERR_BAD_CMAP_FILE); 95 | 96 | /* There must be a global color map. */ 97 | if ((header[10] & 0x80) == 0) 98 | ERREXIT(cinfo, JERR_BAD_CMAP_FILE); 99 | 100 | /* OK, fetch it. */ 101 | colormaplen = 2 << (header[10] & 0x07); 102 | 103 | for (i = 0; i < colormaplen; i++) { 104 | R = getc(infile); 105 | G = getc(infile); 106 | B = getc(infile); 107 | if (R == EOF || G == EOF || B == EOF) 108 | ERREXIT(cinfo, JERR_BAD_CMAP_FILE); 109 | add_map_entry(cinfo, 110 | R << (BITS_IN_JSAMPLE-8), 111 | G << (BITS_IN_JSAMPLE-8), 112 | B << (BITS_IN_JSAMPLE-8)); 113 | } 114 | } 115 | 116 | 117 | /* Support routines for reading PPM */ 118 | 119 | 120 | LOCAL(int) 121 | pbm_getc (FILE * infile) 122 | /* Read next char, skipping over any comments */ 123 | /* A comment/newline sequence is returned as a newline */ 124 | { 125 | register int ch; 126 | 127 | ch = getc(infile); 128 | if (ch == '#') { 129 | do { 130 | ch = getc(infile); 131 | } while (ch != '\n' && ch != EOF); 132 | } 133 | return ch; 134 | } 135 | 136 | 137 | LOCAL(unsigned int) 138 | read_pbm_integer (j_decompress_ptr cinfo, FILE * infile) 139 | /* Read an unsigned decimal integer from the PPM file */ 140 | /* Swallows one trailing character after the integer */ 141 | /* Note that on a 16-bit-int machine, only values up to 64k can be read. */ 142 | /* This should not be a problem in practice. */ 143 | { 144 | register int ch; 145 | register unsigned int val; 146 | 147 | /* Skip any leading whitespace */ 148 | do { 149 | ch = pbm_getc(infile); 150 | if (ch == EOF) 151 | ERREXIT(cinfo, JERR_BAD_CMAP_FILE); 152 | } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); 153 | 154 | if (ch < '0' || ch > '9') 155 | ERREXIT(cinfo, JERR_BAD_CMAP_FILE); 156 | 157 | val = ch - '0'; 158 | while ((ch = pbm_getc(infile)) >= '0' && ch <= '9') { 159 | val *= 10; 160 | val += ch - '0'; 161 | } 162 | return val; 163 | } 164 | 165 | 166 | /* 167 | * Extract color map from a PPM file. 168 | */ 169 | 170 | LOCAL(void) 171 | read_ppm_map (j_decompress_ptr cinfo, FILE * infile) 172 | { 173 | int c; 174 | unsigned int w, h, maxval, row, col; 175 | int R, G, B; 176 | 177 | /* Initial 'P' has already been read by read_color_map */ 178 | c = getc(infile); /* save format discriminator for a sec */ 179 | 180 | /* while we fetch the remaining header info */ 181 | w = read_pbm_integer(cinfo, infile); 182 | h = read_pbm_integer(cinfo, infile); 183 | maxval = read_pbm_integer(cinfo, infile); 184 | 185 | if (w <= 0 || h <= 0 || maxval <= 0) /* error check */ 186 | ERREXIT(cinfo, JERR_BAD_CMAP_FILE); 187 | 188 | /* For now, we don't support rescaling from an unusual maxval. */ 189 | if (maxval != (unsigned int) MAXJSAMPLE) 190 | ERREXIT(cinfo, JERR_BAD_CMAP_FILE); 191 | 192 | switch (c) { 193 | case '3': /* it's a text-format PPM file */ 194 | for (row = 0; row < h; row++) { 195 | for (col = 0; col < w; col++) { 196 | R = read_pbm_integer(cinfo, infile); 197 | G = read_pbm_integer(cinfo, infile); 198 | B = read_pbm_integer(cinfo, infile); 199 | add_map_entry(cinfo, R, G, B); 200 | } 201 | } 202 | break; 203 | 204 | case '6': /* it's a raw-format PPM file */ 205 | for (row = 0; row < h; row++) { 206 | for (col = 0; col < w; col++) { 207 | R = getc(infile); 208 | G = getc(infile); 209 | B = getc(infile); 210 | if (R == EOF || G == EOF || B == EOF) 211 | ERREXIT(cinfo, JERR_BAD_CMAP_FILE); 212 | add_map_entry(cinfo, R, G, B); 213 | } 214 | } 215 | break; 216 | 217 | default: 218 | ERREXIT(cinfo, JERR_BAD_CMAP_FILE); 219 | break; 220 | } 221 | } 222 | 223 | 224 | /* 225 | * Main entry point from djpeg.c. 226 | * Input: opened input file (from file name argument on command line). 227 | * Output: colormap and actual_number_of_colors fields are set in cinfo. 228 | */ 229 | 230 | GLOBAL(void) 231 | read_color_map (j_decompress_ptr cinfo, FILE * infile) 232 | { 233 | /* Allocate space for a color map of maximum supported size. */ 234 | cinfo->colormap = (*cinfo->mem->alloc_sarray) 235 | ((j_common_ptr) cinfo, JPOOL_IMAGE, 236 | (JDIMENSION) (MAXJSAMPLE+1), (JDIMENSION) 3); 237 | cinfo->actual_number_of_colors = 0; /* initialize map to empty */ 238 | 239 | /* Read first byte to determine file format */ 240 | switch (getc(infile)) { 241 | case 'G': 242 | read_gif_map(cinfo, infile); 243 | break; 244 | case 'P': 245 | read_ppm_map(cinfo, infile); 246 | break; 247 | default: 248 | ERREXIT(cinfo, JERR_BAD_CMAP_FILE); 249 | break; 250 | } 251 | } 252 | 253 | #endif /* QUANT_2PASS_SUPPORTED */ 254 | -------------------------------------------------------------------------------- /FlirOneControl/cmainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | CMainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1048 10 | 746 11 | 12 | 13 | 14 | CMainWindow 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | QFrame::Panel 24 | 25 | 26 | QFrame::Plain 27 | 28 | 29 | Коэффициент излучения материала 30 | 31 | 32 | 33 | 34 | 35 | 36 | Сохранять файл RAW 37 | 38 | 39 | 40 | 41 | 42 | 43 | Сохранять кадры с видеокамеры 44 | 45 | 46 | 47 | 48 | 49 | 50 | Палитра 51 | 52 | 53 | 54 | 55 | 56 | 57 | Показывать видео 58 | 59 | 60 | 61 | 62 | 63 | 64 | Сохранять изображения без шкалы 65 | 66 | 67 | 68 | 69 | 70 | 71 | 0.010000000000000 72 | 73 | 74 | 1.000000000000000 75 | 76 | 77 | 0.100000000000000 78 | 79 | 80 | 0.950000000000000 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | Применить палитру 91 | 92 | 93 | 94 | 95 | 96 | 97 | QFrame::Panel 98 | 99 | 100 | Температура болометров, C 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 0 109 | 0 110 | 111 | 112 | 113 | Сохранять все кадры 114 | 115 | 116 | 117 | 118 | 119 | 120 | Сохранять с кадры с перекрестьем 121 | 122 | 123 | 124 | 125 | 126 | 127 | -99.989999999999995 128 | 129 | 130 | 0.100000000000000 131 | 132 | 133 | 20.000000000000000 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | Нижняя граница температуры для сигнализации 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 0 156 | 0 157 | 158 | 159 | 160 | Сохранить один кадр 161 | 162 | 163 | 164 | 165 | 166 | 167 | -300.000000000000000 168 | 169 | 170 | 300.000000000000000 171 | 172 | 173 | 100.000000000000000 174 | 175 | 176 | 177 | 178 | 179 | 180 | Верхняя граница температуры для сигнализации 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | -300.000000000000000 195 | 196 | 197 | 300.000000000000000 198 | 199 | 200 | -100.000000000000000 201 | 202 | 203 | 204 | 205 | 206 | 207 | При выходе за границы температуры выполнить: 208 | 209 | 210 | 211 | 212 | 213 | 214 | Сохранить кадр 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | --------------------------------------------------------------------------------