Compare commits
32 Commits
87a35f5dd4
...
push_strea
Author | SHA1 | Date | |
---|---|---|---|
a91f5f5b04 | |||
2e4679aaef | |||
061e1f83bd | |||
d0b67b47c1 | |||
7fa3b70d10 | |||
781b33f577 | |||
f33103c970 | |||
a341e0b2c5 | |||
19e2309be7 | |||
a492baea18 | |||
096df8075c | |||
ba1b01bccc | |||
e4a7c4481b | |||
1476c2bc15 | |||
6d6b662cec | |||
2e158431e7 | |||
6473a1f4ce | |||
cc76d62ded | |||
e620c87ecf | |||
47002ad894 | |||
5337a40837 | |||
6b78db5bc3 | |||
73f9b00b02 | |||
6fc2680a1c | |||
09d224075a | |||
371c422a34 | |||
b31cd5fc8a | |||
447a1aafb1 | |||
e96953b54a | |||
da57cc8e87 | |||
cbff36447b | |||
627f666d30 |
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
cmake_minimum_required(VERSION 3.5.2)
|
||||
project(ximeaAirborneSystem)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
@ -9,7 +9,7 @@ set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
set(QT Core Network SerialPort)
|
||||
set(QT Core Network SerialPort Gui)
|
||||
set(TEMPLATE app)
|
||||
set(TARGET ximeaImageRecorder)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
@ -17,9 +17,15 @@ find_package(Qt5 REQUIRED ${QT})#
|
||||
|
||||
include_directories(.)
|
||||
include_directories(/home/300tc/library/ximeaControlDll/Header_Files)
|
||||
|
||||
link_directories(/home/300tc/library/ximeaControlDll)
|
||||
|
||||
find_package(OpenCV 4.2.0 REQUIRED)
|
||||
include_directories(/usr/local/include/opencv4/)
|
||||
link_directories(/usr/local/lib)
|
||||
|
||||
include_directories(/home/300tc/library/ffmpeg_build/include)
|
||||
link_directories(/home/300tc/library/ffmpeg_build/lib)
|
||||
|
||||
add_executable(${CMAKE_PROJECT_NAME}
|
||||
Source_Files/fileoperation.cpp
|
||||
Header_Files/fileoperation.h
|
||||
@ -41,10 +47,17 @@ add_executable(${CMAKE_PROJECT_NAME}
|
||||
Source_Files/ximeaimager.cpp
|
||||
Header_Files/ximeaimager.h
|
||||
Source_Files/configfile.cpp
|
||||
Header_Files/configfile.h)
|
||||
Header_Files/configfile.h
|
||||
Header_Files/MemoryPool.tcc
|
||||
Header_Files/MemoryPool.h Source_Files/rgbImage.cpp Header_Files/rgbImage.h)
|
||||
qt5_use_modules(${CMAKE_PROJECT_NAME} ${QT})
|
||||
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}
|
||||
irisXimeaImager
|
||||
libconfig.so
|
||||
libconfig++.so)
|
||||
libconfig++.so
|
||||
${OpenCV_LIBS}
|
||||
avformat
|
||||
avcodec
|
||||
swscale
|
||||
avutil)
|
||||
|
98
Header_Files/MemoryPool.h
Normal file
98
Header_Files/MemoryPool.h
Normal file
@ -0,0 +1,98 @@
|
||||
/*-
|
||||
* Copyright (c) 2013 Cosku Acay, http://www.coskuacay.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MEMORY_POOL_H
|
||||
#define MEMORY_POOL_H
|
||||
|
||||
#include <climits>
|
||||
#include <cstddef>
|
||||
|
||||
template <typename T, size_t BlockSize = 409200000>
|
||||
class MemoryPool
|
||||
{
|
||||
public:
|
||||
/* Member types */
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
typedef const T* const_pointer;
|
||||
typedef const T& const_reference;
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef std::false_type propagate_on_container_copy_assignment;
|
||||
typedef std::true_type propagate_on_container_move_assignment;
|
||||
typedef std::true_type propagate_on_container_swap;
|
||||
|
||||
template <typename U> struct rebind {
|
||||
typedef MemoryPool<U> other;
|
||||
};
|
||||
|
||||
/* Member functions */
|
||||
MemoryPool() noexcept;
|
||||
MemoryPool(const MemoryPool& memoryPool) noexcept;
|
||||
MemoryPool(MemoryPool&& memoryPool) noexcept;
|
||||
template <class U> MemoryPool(const MemoryPool<U>& memoryPool) noexcept;
|
||||
|
||||
~MemoryPool() noexcept;
|
||||
|
||||
MemoryPool& operator=(const MemoryPool& memoryPool) = delete;
|
||||
MemoryPool& operator=(MemoryPool&& memoryPool) noexcept;
|
||||
|
||||
pointer address(reference x) const noexcept;
|
||||
const_pointer address(const_reference x) const noexcept;
|
||||
|
||||
// Can only allocate one object at a time. n and hint are ignored
|
||||
pointer allocate(size_type n = 1, const_pointer hint = 0);
|
||||
void deallocate(pointer p, size_type n = 1);
|
||||
|
||||
size_type max_size() const noexcept;
|
||||
|
||||
template <class U, class... Args> void construct(U* p, Args&&... args);
|
||||
template <class U> void destroy(U* p);
|
||||
|
||||
template <class... Args> pointer newElement(Args&&... args);
|
||||
void deleteElement(pointer p);
|
||||
|
||||
private:
|
||||
union Slot_ {
|
||||
value_type element;
|
||||
Slot_* next;
|
||||
};
|
||||
|
||||
typedef char* data_pointer_;
|
||||
typedef Slot_ slot_type_;
|
||||
typedef Slot_* slot_pointer_;
|
||||
|
||||
slot_pointer_ currentBlock_;
|
||||
slot_pointer_ currentSlot_;
|
||||
slot_pointer_ lastSlot_;
|
||||
slot_pointer_ freeSlots_;
|
||||
|
||||
size_type padPointer(data_pointer_ p, size_type align) const noexcept;
|
||||
void allocateBlock();
|
||||
|
||||
static_assert(BlockSize >= 2 * sizeof(slot_type_), "BlockSize too small.");
|
||||
};
|
||||
|
||||
#include "MemoryPool.tcc"
|
||||
|
||||
#endif // MEMORY_POOL_H
|
235
Header_Files/MemoryPool.tcc
Normal file
235
Header_Files/MemoryPool.tcc
Normal file
@ -0,0 +1,235 @@
|
||||
/*-
|
||||
* Copyright (c) 2013 Cosku Acay, http://www.coskuacay.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MEMORY_BLOCK_TCC
|
||||
#define MEMORY_BLOCK_TCC
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
inline typename MemoryPool<T, BlockSize>::size_type
|
||||
MemoryPool<T, BlockSize>::padPointer(data_pointer_ p, size_type align)
|
||||
const noexcept
|
||||
{
|
||||
uintptr_t result = reinterpret_cast<uintptr_t>(p);
|
||||
return ((align - result) % align);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
MemoryPool<T, BlockSize>::MemoryPool()
|
||||
noexcept
|
||||
{
|
||||
currentBlock_ = nullptr;
|
||||
currentSlot_ = nullptr;
|
||||
lastSlot_ = nullptr;
|
||||
freeSlots_ = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
MemoryPool<T, BlockSize>::MemoryPool(const MemoryPool& memoryPool)
|
||||
noexcept :
|
||||
MemoryPool()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
MemoryPool<T, BlockSize>::MemoryPool(MemoryPool&& memoryPool)
|
||||
noexcept
|
||||
{
|
||||
currentBlock_ = memoryPool.currentBlock_;
|
||||
memoryPool.currentBlock_ = nullptr;
|
||||
currentSlot_ = memoryPool.currentSlot_;
|
||||
lastSlot_ = memoryPool.lastSlot_;
|
||||
freeSlots_ = memoryPool.freeSlots;
|
||||
}
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
template<class U>
|
||||
MemoryPool<T, BlockSize>::MemoryPool(const MemoryPool<U>& memoryPool)
|
||||
noexcept :
|
||||
MemoryPool()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
MemoryPool<T, BlockSize>&
|
||||
MemoryPool<T, BlockSize>::operator=(MemoryPool&& memoryPool)
|
||||
noexcept
|
||||
{
|
||||
if (this != &memoryPool)
|
||||
{
|
||||
std::swap(currentBlock_, memoryPool.currentBlock_);
|
||||
currentSlot_ = memoryPool.currentSlot_;
|
||||
lastSlot_ = memoryPool.lastSlot_;
|
||||
freeSlots_ = memoryPool.freeSlots;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
MemoryPool<T, BlockSize>::~MemoryPool()
|
||||
noexcept
|
||||
{
|
||||
slot_pointer_ curr = currentBlock_;
|
||||
while (curr != nullptr) {
|
||||
slot_pointer_ prev = curr->next;
|
||||
operator delete(reinterpret_cast<void*>(curr));
|
||||
curr = prev;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
inline typename MemoryPool<T, BlockSize>::pointer
|
||||
MemoryPool<T, BlockSize>::address(reference x)
|
||||
const noexcept
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
inline typename MemoryPool<T, BlockSize>::const_pointer
|
||||
MemoryPool<T, BlockSize>::address(const_reference x)
|
||||
const noexcept
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
void
|
||||
MemoryPool<T, BlockSize>::allocateBlock()
|
||||
{
|
||||
// Allocate space for the new block and store a pointer to the previous one
|
||||
data_pointer_ newBlock = reinterpret_cast<data_pointer_>
|
||||
(operator new(BlockSize));
|
||||
reinterpret_cast<slot_pointer_>(newBlock)->next = currentBlock_;
|
||||
currentBlock_ = reinterpret_cast<slot_pointer_>(newBlock);
|
||||
// Pad block body to staisfy the alignment requirements for elements
|
||||
data_pointer_ body = newBlock + sizeof(slot_pointer_);
|
||||
size_type bodyPadding = padPointer(body, alignof(slot_type_));
|
||||
currentSlot_ = reinterpret_cast<slot_pointer_>(body + bodyPadding);
|
||||
lastSlot_ = reinterpret_cast<slot_pointer_>
|
||||
(newBlock + BlockSize - sizeof(slot_type_) + 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
inline typename MemoryPool<T, BlockSize>::pointer
|
||||
MemoryPool<T, BlockSize>::allocate(size_type n, const_pointer hint)
|
||||
{
|
||||
if (freeSlots_ != nullptr) {
|
||||
pointer result = reinterpret_cast<pointer>(freeSlots_);
|
||||
freeSlots_ = freeSlots_->next;
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
if (currentSlot_ >= lastSlot_)
|
||||
allocateBlock();
|
||||
return reinterpret_cast<pointer>(currentSlot_++);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
inline void
|
||||
MemoryPool<T, BlockSize>::deallocate(pointer p, size_type n)
|
||||
{
|
||||
if (p != nullptr) {
|
||||
reinterpret_cast<slot_pointer_>(p)->next = freeSlots_;
|
||||
freeSlots_ = reinterpret_cast<slot_pointer_>(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
inline typename MemoryPool<T, BlockSize>::size_type
|
||||
MemoryPool<T, BlockSize>::max_size()
|
||||
const noexcept
|
||||
{
|
||||
size_type maxBlocks = -1 / BlockSize;
|
||||
return (BlockSize - sizeof(data_pointer_)) / sizeof(slot_type_) * maxBlocks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
template <class U, class... Args>
|
||||
inline void
|
||||
MemoryPool<T, BlockSize>::construct(U* p, Args&&... args)
|
||||
{
|
||||
new (p) U (std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
template <class U>
|
||||
inline void
|
||||
MemoryPool<T, BlockSize>::destroy(U* p)
|
||||
{
|
||||
p->~U();
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
template <class... Args>
|
||||
inline typename MemoryPool<T, BlockSize>::pointer
|
||||
MemoryPool<T, BlockSize>::newElement(Args&&... args)
|
||||
{
|
||||
pointer result = allocate();
|
||||
construct<value_type>(result, std::forward<Args>(args)...);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, size_t BlockSize>
|
||||
inline void
|
||||
MemoryPool<T, BlockSize>::deleteElement(pointer p)
|
||||
{
|
||||
if (p != nullptr) {
|
||||
p->~value_type();
|
||||
deallocate(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // MEMORY_BLOCK_TCC
|
@ -9,12 +9,15 @@
|
||||
#include <iomanip>
|
||||
#include <cstdlib>
|
||||
#include <libconfig.h++>
|
||||
#include <string>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QString>
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
|
||||
#include "utility_tc.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace libconfig;
|
||||
|
||||
@ -31,7 +34,15 @@ public:
|
||||
bool getspatialBin(int &spatialBin);
|
||||
bool getEffectiveWindow(int &width, int &offsetx, int &height, int &offsety);
|
||||
bool getEffectiveWindowRoi(int &width, int &offsetx);
|
||||
bool getWindowOffsety_HeightOfSpectral(int &offsety, int &height, string spectralBinString);//spectralBinString = "bin1"或者”bin2“
|
||||
bool getGainOffset(float &gain, float &offset);
|
||||
bool getGainOffsetOfSpectralBin1(float &gain, float &offset);
|
||||
bool getSN(QString &SN);
|
||||
|
||||
bool getBufferPolicy(int &bufferPolicy);
|
||||
bool getAcqBufferSize(int &acqBufferSize);
|
||||
|
||||
bool getPushFlowParam(int &flowSwitch, int &rgbHeight, int &framerateVideo);
|
||||
|
||||
bool createConfigFile();
|
||||
bool updateConfigFile();
|
||||
@ -40,4 +51,55 @@ private:
|
||||
string m_configfilePath;
|
||||
Config cfg;
|
||||
};
|
||||
|
||||
class ParameterConfigfile
|
||||
{
|
||||
public:
|
||||
ParameterConfigfile();
|
||||
void setConfigfilePath(string configfilePath);
|
||||
bool isConfigfileExist();
|
||||
bool parseConfigfile();
|
||||
|
||||
bool getFrameRate(int &frameRate);
|
||||
bool setFrameRate(int frameRate);
|
||||
|
||||
bool getExposeTime(float &exposeTime);
|
||||
bool setExposeTime(float exposeTime);
|
||||
|
||||
bool createConfigFile();
|
||||
// bool updateConfigFile();
|
||||
bool writeConfig2File();
|
||||
|
||||
string m_configfilePath;
|
||||
Config cfg;
|
||||
private:
|
||||
};
|
||||
|
||||
class StateOf300tcConfigfile:public ParameterConfigfile
|
||||
{
|
||||
public:
|
||||
StateOf300tcConfigfile();
|
||||
|
||||
bool getSwitchState(bool &switchState);
|
||||
bool setSwitchState(bool switchState);
|
||||
|
||||
bool getSbgState(int &sbgState);
|
||||
bool setSbgState(int sbgState);
|
||||
|
||||
bool getSbgSolutionMode(int &sbgSolutionMode);
|
||||
bool setSbgSolutionMode(int sbgSolutionMode);
|
||||
|
||||
bool getXimeaState(int &ximeaState);
|
||||
bool setXimeaState(int ximeaState);
|
||||
|
||||
bool getExposeMaxValueOfOneFrame(int &exposeMaxValueOfOneFrame);
|
||||
bool setExposeMaxValueOfOneFrame(int exposeMaxValueOfOneFrame);
|
||||
|
||||
bool createConfigFile();
|
||||
|
||||
private:
|
||||
bool getIntValue(int &value, string field);
|
||||
bool setIntValue(int value, string field);
|
||||
|
||||
};
|
||||
#endif //XIMEAIMAGERECORDER_CONFIGFILE_H
|
||||
|
84
Header_Files/rgbImage.h
Normal file
84
Header_Files/rgbImage.h
Normal file
@ -0,0 +1,84 @@
|
||||
//
|
||||
// Created by tangchao on 2022/12/24.
|
||||
//
|
||||
|
||||
#ifndef XIMEAAIRBORNESYSTEM_RGBIMAGE_H
|
||||
#define XIMEAAIRBORNESYSTEM_RGBIMAGE_H
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <QObject>
|
||||
#include <QImage>
|
||||
#include <opencv2/opencv.hpp>//包含了所有东西,编译很慢
|
||||
#include "opencv2/imgproc/types_c.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavutil/opt.h>
|
||||
#include "libavutil/pixfmt.h"
|
||||
#include "libswscale/swscale.h"
|
||||
#include <libavutil/imgutils.h>
|
||||
#include <libavutil/avutil.h>
|
||||
#include "libavdevice/avdevice.h"
|
||||
}
|
||||
|
||||
using namespace cv;
|
||||
class rgbImage :public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
rgbImage(QWidget* pParent = NULL);
|
||||
~rgbImage();
|
||||
|
||||
void SetRgbImageWidthAndHeight(int BandCount, int Width, int height);
|
||||
void SetRgbBandNumber(int redBandNumber, int greenBandNumber, int blueBandNumber);
|
||||
void FillRgbImage(unsigned short *datacube);
|
||||
void FillFocusGrayImage(unsigned short *datacube);
|
||||
void FillFocusGrayQImage(unsigned short * datacube);
|
||||
|
||||
void FillOnerowofRgbImage(cv::Mat * matRgbImage, int rowNumber, unsigned short *datacube);
|
||||
QImage Mat2QImage(cv::Mat cvImg);//https://www.cnblogs.com/annt/p/ant003.html
|
||||
|
||||
QImage *m_QRgbImage;
|
||||
cv::Mat *m_matRgbImage;
|
||||
QImage m_Qphoto;
|
||||
|
||||
QImage *m_qimageFocusGrayImage;
|
||||
cv::Mat *m_matFocusGrayImage;//用于调焦时,显示一帧的灰度图
|
||||
//cv::Mat m_matFocusGrayImage;//用于调焦时,显示一帧的灰度图
|
||||
|
||||
CvVideoWriter *m_frame_writer;
|
||||
VideoWriter m_VideoWriter;
|
||||
// VideoWriter m_video("appsrc ! autovideoconvert ! filesink location=/media/nvme/delete/live.avi", CV_FOURCC('M', 'J', 'P', 'G'), 25.0, Size(640, 480));
|
||||
// VideoWriter video("test.avi", CV_FOURCC('M', 'J', 'P', 'G'), 25.0, Size(640, 480));//
|
||||
|
||||
//控制该填充rgb图像第几帧(行)数据
|
||||
//以下两种情况需要重置为0:1)调用函数SetRgbImageWidthAndHeight;2)每次开始填充数据前
|
||||
int m_iFrameCounter;
|
||||
int m_iFramerate;//
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
int m_iSampleNumber;//
|
||||
int m_iBandNumber;//
|
||||
|
||||
int m_iFrameNumber;//
|
||||
|
||||
void initffmpeg();
|
||||
|
||||
int m_iRedBandNumber;
|
||||
int m_iGreenBandNumber;
|
||||
int m_iBlueBandNumber;
|
||||
|
||||
public slots:
|
||||
|
||||
signals :
|
||||
void sendstr(QString str);
|
||||
void sendstr1(QString str);
|
||||
void refreslabelimg(QImage* img1);
|
||||
};
|
||||
#endif //XIMEAAIRBORNESYSTEM_RGBIMAGE_H
|
@ -69,8 +69,7 @@ namespace sbgtc
|
||||
|
||||
void sbgSolutionModeSignal(int);
|
||||
|
||||
void sbgAccuracySignal(int);
|
||||
|
||||
void sbgAccuracySignal(int, int);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -11,17 +11,43 @@
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QDir>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
|
||||
#include "ximeaimager.h"
|
||||
#include "sbgrecorder.h"
|
||||
#include "fileoperation.h"
|
||||
|
||||
#include "configfile.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// #include <sbgEComLib.h>
|
||||
#include <stdlib.h>
|
||||
}
|
||||
|
||||
class Record300TcTemperature : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Record300TcTemperature();
|
||||
|
||||
void stopRecordTemperature();
|
||||
|
||||
private:
|
||||
bool m_bIsRecord;
|
||||
|
||||
QSerialPort * m_serial;
|
||||
|
||||
float parseMessage(QByteArray * data);
|
||||
public slots:
|
||||
void recordTemperature(QString filePath);
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
class UdpServer:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -48,6 +74,11 @@ class UdpServer:public QObject
|
||||
|
||||
void sender(int status);
|
||||
|
||||
QThread * m_recordTempThread;
|
||||
Record300TcTemperature * m_300tcTemperature;
|
||||
|
||||
StateOf300tcConfigfile stateOf300tc;
|
||||
|
||||
signals:
|
||||
void systemStart();
|
||||
void systemStop();
|
||||
@ -56,6 +87,7 @@ signals:
|
||||
void startDeleteFileSignal();
|
||||
|
||||
void recordXimeaOnlySignal(double,QString);
|
||||
void record300tcTemperatureSignal(QString);
|
||||
|
||||
public slots:
|
||||
void onRecordFinished();
|
||||
@ -63,9 +95,12 @@ public slots:
|
||||
void sendSerialPortStatus(int serialPortStatus);
|
||||
|
||||
void sendSbgSolutionModeState(int SolutionMode);
|
||||
void sendSbgAccuracyState(int Accuracy);
|
||||
void sendSbgAccuracyState(int Accuracy,int SatelliteCounter);
|
||||
|
||||
void sendXimeaImageStatus(int ximeaImageStatus);
|
||||
void sendXimeaAutoExposeMaxValueOfOneFrame(int autoExposeMaxValueOfOneFrame, double exposeTime);
|
||||
void sendXimeaBinState(int spatialBin, int spectralBin);
|
||||
void sendXimeaImageFrameRate(double frameRate);
|
||||
void sendCopyFileStatus(int fileStatus);
|
||||
};
|
||||
#endif // UDPSERVER_H
|
||||
|
@ -2,15 +2,22 @@
|
||||
#define UTILITY_TC_H
|
||||
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
||||
QString getFileNameBaseOnTime();
|
||||
|
||||
QString formatTimeStr(char * format);
|
||||
|
||||
//https://blog.csdn.net/MoreWindows/article/details/6657829
|
||||
void bubbleSort(unsigned short * a, int n);
|
||||
|
||||
void swap(unsigned short * a, unsigned short * b);
|
||||
|
||||
bool createDir(QString fullPath);
|
||||
|
||||
QList<QString> getFileInfo(QString file);
|
||||
|
||||
#endif // UTILITY_TC_H
|
||||
|
@ -25,6 +25,10 @@
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
#include <exception>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
@ -37,6 +41,16 @@
|
||||
#include "math.h"
|
||||
#include "utility_tc.h"
|
||||
|
||||
#include "MemoryPool.h"
|
||||
#include <queue>
|
||||
#include <QMutex>
|
||||
#include <QUdpSocket>
|
||||
|
||||
#include "rgbImage.h"
|
||||
|
||||
#define PUSH_FLOW_PORT 666
|
||||
|
||||
|
||||
|
||||
//#ifdef WIN32
|
||||
//#include <xiApi.h> // Windows
|
||||
@ -44,12 +58,30 @@
|
||||
//#include <m3api/xiApi.h> // Linux, OSX
|
||||
//#endif
|
||||
|
||||
//struct DataBuffer
|
||||
//{
|
||||
// unsigned short data[409200/2];
|
||||
//};
|
||||
|
||||
class DataBuffer
|
||||
{
|
||||
public:
|
||||
DataBuffer();
|
||||
~DataBuffer();
|
||||
|
||||
unsigned short data[41040000];//1368*300*100=41040000,为了兼容所有设置spectral bin和spatial bin
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
class XimeaImager;
|
||||
class RecordXimeaTemperature : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RecordXimeaTemperature(Iris::IrisXimeaImager * imager);
|
||||
RecordXimeaTemperature(Iris::IrisXimeaImager * imager, XimeaImager * ximeaImager);
|
||||
|
||||
void stopRecordTemperature();
|
||||
|
||||
@ -57,6 +89,7 @@ private:
|
||||
Iris::IrisXimeaImager * m_imager;
|
||||
|
||||
bool m_bIsRecord;
|
||||
XimeaImager * m_ximeaImager;
|
||||
public slots:
|
||||
void recordTemperature(QString filePath);
|
||||
|
||||
@ -64,16 +97,74 @@ signals:
|
||||
|
||||
};
|
||||
|
||||
//queue<DataBuffer *> q;
|
||||
//static QMutex r_qtx{ QMutex::Recursive };
|
||||
static std::mutex r_qtx;
|
||||
|
||||
class WriteData2Disk : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
WriteData2Disk();
|
||||
void setParm(queue<DataBuffer *> * q, queue<int> * qFrameCounter, QString baseFileName, int frameSizeInByte, int number_WriteDisk, MemoryPool<DataBuffer> * pool, rgbImage * rgbImage);
|
||||
|
||||
private:
|
||||
queue<DataBuffer *> * m_q;
|
||||
queue<int> * m_qFrameCounter;
|
||||
QString m_QbaseFileName;
|
||||
int m_iFrameSizeInByte;
|
||||
int m_iNumber_WriteDisk;
|
||||
MemoryPool<DataBuffer> * m_pool;
|
||||
bool isExitWriteData2Disk;
|
||||
|
||||
rgbImage * m_rgbImage;
|
||||
|
||||
public slots:
|
||||
void write2Disk();
|
||||
void exitWriteData2Disk();
|
||||
|
||||
signals:
|
||||
};
|
||||
|
||||
class PushFlow : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PushFlow();
|
||||
void setParm(rgbImage * img, int width, int height, int framerateVideo);
|
||||
void exitPushFlow();
|
||||
void setVedioFilePath(QString path);
|
||||
|
||||
private:
|
||||
QString m_QVedioFilePath;
|
||||
bool isExitPushFlow;
|
||||
|
||||
rgbImage * m_rgbImage;
|
||||
|
||||
int m_iWidth;
|
||||
int m_iHeight;
|
||||
int m_iFramerateVideo;
|
||||
|
||||
public slots:
|
||||
void encodePushFlow();
|
||||
|
||||
signals:
|
||||
};
|
||||
|
||||
class XimeaImager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
XimeaImager();
|
||||
~XimeaImager();
|
||||
|
||||
void setFramerate(double framerate);
|
||||
double getFramerate();
|
||||
double setExposureTime(float exposureTime);
|
||||
double setExposureTime(float exposureTime_in_us);
|
||||
int wrapSetExposureTime(float exposureTime_in_us);
|
||||
double getExposureTime();
|
||||
double autoExposure();
|
||||
void setGain(double gain);
|
||||
@ -85,8 +176,12 @@ public:
|
||||
int getWindowEndBand();
|
||||
double geWavelengthAtBand(int x);
|
||||
|
||||
static int findClosestIndex(const std::vector<double>& numbers, double target);
|
||||
void getRgbBandNumber(int &redBandNumber, int &greenBandNumber, int &blueBandNumber);
|
||||
|
||||
void stopRecord();
|
||||
int getFrameCounter();
|
||||
void writeXiApiErrorCodes(QString filePath, int xiApiErrorCodes);
|
||||
|
||||
int getMaxValueOfOneFrame(unsigned short * data, int numberOfPixel);
|
||||
|
||||
@ -96,46 +191,52 @@ private:
|
||||
int m_iImagerState;
|
||||
int m_iImagerStateTemp;
|
||||
|
||||
int m_iOffsetyOfSpectralBin1, m_iOffsetyOfSpectralBin2;
|
||||
int m_iHeightOfSpectralBin1, m_iHeightOfSpectralBin2;
|
||||
|
||||
QThread * m_recordTempThread;
|
||||
RecordXimeaTemperature * m_ximeaTemperature;
|
||||
|
||||
QThread * writeData2DiskThread;
|
||||
WriteData2Disk * writeData2Disk;
|
||||
queue<DataBuffer *> * q;
|
||||
queue<int> * m_qFrameCounter;
|
||||
MemoryPool<DataBuffer> * m_pool;
|
||||
|
||||
QThread * m_pushFlowThread;
|
||||
PushFlow * m_pushFlow;
|
||||
int m_iFlowSwitch;
|
||||
|
||||
QString m_baseFileName;
|
||||
QString m_ximeaTemperatureCSVPath;
|
||||
|
||||
Iris::IrisXimeaImager m_imager;
|
||||
unsigned short * m_buffer;
|
||||
// MemoryPool<unsigned short> m_pool;
|
||||
bool m_bRecordControl;
|
||||
int m_iFrameCounter;
|
||||
int m_iFrameSizeInByte;
|
||||
rgbImage * m_rgbImage;
|
||||
void writeHdr();
|
||||
|
||||
void processXiApiErrorCodes(int xiApiErrorCodes);
|
||||
|
||||
inline double getSbgTime(double TimeDifferenceBetweensOSAndSbg)
|
||||
inline double getSbgTime(XI_IMG * image, double timeDifferenceBetweenSbgAndXimea)
|
||||
{
|
||||
struct timespec systemTime;
|
||||
clock_gettime(CLOCK_REALTIME,&systemTime);
|
||||
tm systemTime_rili;
|
||||
localtime_r(&systemTime.tv_sec, &systemTime_rili);
|
||||
|
||||
double secondSystem=(systemTime_rili.tm_mday-1)*24*60*60+systemTime_rili.tm_hour*60*60+systemTime_rili.tm_min*60+systemTime_rili.tm_sec;
|
||||
double nanosecondSystem=secondSystem+static_cast<double>(systemTime.tv_nsec)/1000000000;
|
||||
|
||||
|
||||
// printf("\n");
|
||||
// printf("XimeaImager::getSbgTime------系统时间纳秒%d\n", systemTime.tv_nsec);
|
||||
// printf("XimeaImager::getSbgTime------系统时间(未偏移)%f\n", nanosecondSystem);
|
||||
// printf("XimeaImager::getSbgTime------系统时间(偏移)%f\n", nanosecondSystem-TimeDifferenceBetweensOSAndSbg);
|
||||
|
||||
return nanosecondSystem-TimeDifferenceBetweensOSAndSbg;
|
||||
double ximeaTime = (double)image->tsSec + (double)image->tsUSec/1000000;
|
||||
return ximeaTime + timeDifferenceBetweenSbgAndXimea;
|
||||
}
|
||||
|
||||
Configfile m_configfile;
|
||||
ParameterConfigfile m_parameterConfigfile;
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
void openImger();
|
||||
void closeImger();
|
||||
|
||||
double calculateTimeDifferenceBetweenSbgAndximea(XI_IMG * m_image, double timeDifferenceBetweenSbgAndOS);
|
||||
void startRecord(double TimeDifferenceBetweensOSAndSbg,QString baseFileName);
|
||||
|
||||
signals:
|
||||
@ -143,5 +244,11 @@ signals:
|
||||
void ximeaImageStatus(int);
|
||||
|
||||
void recordXimeaTemperatureSignal(QString);
|
||||
void startWriteDiskSignal();
|
||||
void startPushFlowSignal();
|
||||
|
||||
void autoExposeMaxValueOfOneFrame(int, double);
|
||||
void frameRateSignal(double);
|
||||
void binSignal(int, int);
|
||||
};
|
||||
#endif // XIMEAIMAGER_H
|
||||
|
@ -166,6 +166,86 @@ bool Configfile::getEffectiveWindowRoi(int &width, int &offsetx)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::getPushFlowParam(int &flowSwitch, int &rgbHeight, int &framerateVideo)
|
||||
{
|
||||
Setting& root = cfg.getRoot();
|
||||
|
||||
if (!root.exists("push_flow_param"))
|
||||
{
|
||||
// 配置项不存在,添加配置项
|
||||
Setting & push_flow_param = root.add("push_flow_param", Setting::TypeGroup);
|
||||
|
||||
push_flow_param.add("flow_switch", Setting::TypeInt) = 0;
|
||||
push_flow_param.add("rgb_height", Setting::TypeInt) = 720;
|
||||
push_flow_param.add("framerate_video", Setting::TypeInt) = 5;
|
||||
|
||||
// 保存修改后的配置到文件
|
||||
try
|
||||
{
|
||||
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
|
||||
bool ret = createDir(fileInfo[0]);
|
||||
|
||||
cfg.writeFile(m_configfilePath.c_str());
|
||||
std::cout << "Config item 'push_flow_param' added." << std::endl;
|
||||
|
||||
flowSwitch = 0;
|
||||
rgbHeight = 720;
|
||||
framerateVideo = 5;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (const libconfig::FileIOException &fioex)
|
||||
{
|
||||
std::cerr << "I/O error while writing file." << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
const Setting &push_flow_param = root["push_flow_param"];
|
||||
|
||||
if(!(push_flow_param.lookupValue("rgb_height", rgbHeight)
|
||||
&& push_flow_param.lookupValue("framerate_video", framerateVideo)
|
||||
&& push_flow_param.lookupValue("flow_switch", flowSwitch)
|
||||
))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
// Ignore.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool Configfile::getWindowOffsety_HeightOfSpectral(int &offsety, int &height, string spectralBinString)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
|
||||
try
|
||||
{
|
||||
const Setting &spectralArgument = root["effective_window"][spectralBinString]["spectral"];
|
||||
if(!(spectralArgument.lookupValue("height", height)
|
||||
&& spectralArgument.lookupValue("offsety", offsety)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
// Ignore.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::getGainOffset(float &gain, float &offset)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
@ -206,6 +286,95 @@ bool Configfile::getGainOffset(float &gain, float &offset)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::getGainOffsetOfSpectralBin1(float &gain, float &offset)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
|
||||
try
|
||||
{
|
||||
const Setting &gainOffset = root["gainOffset"];
|
||||
int count = gainOffset.getLength();
|
||||
|
||||
string spectralBinString = "spectralBin1";
|
||||
|
||||
const Setting &gainOffsetSetting = gainOffset[spectralBinString];
|
||||
string name = gainOffsetSetting.getName();
|
||||
|
||||
if(!(gainOffsetSetting.lookupValue("gain", gain)
|
||||
&& gainOffsetSetting.lookupValue("offset", offset)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
// Ignore.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::getSN(QString &SN)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string SN_tem = cfg.lookup("SN");
|
||||
SN = QString::fromStdString(SN_tem);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No 'spectralBin' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Configfile::getBufferPolicy(int &bufferPolicy)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
const Setting &ximeadll = root["ximeadll"];
|
||||
|
||||
try
|
||||
{
|
||||
if(!(ximeadll.lookupValue("buffer_policy", bufferPolicy)
|
||||
))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No 'spectralBin' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::getAcqBufferSize(int &acqBufferSize)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
const Setting &ximeadll = root["ximeadll"];
|
||||
|
||||
try
|
||||
{
|
||||
if(!(ximeadll.lookupValue("acq_buffer_size", acqBufferSize)
|
||||
))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No 'spectralBin' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Configfile::createConfigFile()
|
||||
{
|
||||
using namespace std;
|
||||
@ -217,7 +386,7 @@ bool Configfile::createConfigFile()
|
||||
|
||||
// Add some settings to the configuration.
|
||||
Setting &SN = root.add("SN", Setting::TypeString) = "0098";
|
||||
Setting &spatialBin = root.add("spatialBin", Setting::TypeInt) = 1;
|
||||
Setting &spatialBin = root.add("spatialBin", Setting::TypeInt) = 2;
|
||||
Setting &SpectralBin = root.add("spectralBin", Setting::TypeInt) = 2;
|
||||
|
||||
Setting &effective_window = root.add("effective_window", Setting::TypeGroup);
|
||||
@ -228,13 +397,13 @@ bool Configfile::createConfigFile()
|
||||
Setting &effective_window_Bin2_spatial = effective_window_Bin2.add("spatial", Setting::TypeGroup);
|
||||
Setting &effective_window_Bin2_Spectral = effective_window_Bin2.add("spectral", Setting::TypeGroup);
|
||||
|
||||
effective_window_Bin1_spatial.add("width", Setting::TypeInt) = 1392;
|
||||
effective_window_Bin1_spatial.add("offsetx", Setting::TypeInt) = 272;
|
||||
effective_window_Bin1_spatial.add("width", Setting::TypeInt) = 1368;
|
||||
effective_window_Bin1_spatial.add("offsetx", Setting::TypeInt) = 288;
|
||||
effective_window_Bin1_Spectral.add("height", Setting::TypeInt) = 300;
|
||||
effective_window_Bin1_Spectral.add("offsety", Setting::TypeInt) = 348;
|
||||
|
||||
effective_window_Bin2_spatial.add("width", Setting::TypeInt) = 712;
|
||||
effective_window_Bin2_spatial.add("offsetx", Setting::TypeInt) = 128;
|
||||
effective_window_Bin2_spatial.add("width", Setting::TypeInt) = 688;
|
||||
effective_window_Bin2_spatial.add("offsetx", Setting::TypeInt) = 144;
|
||||
effective_window_Bin2_Spectral.add("height", Setting::TypeInt) = 150;
|
||||
effective_window_Bin2_Spectral.add("offsety", Setting::TypeInt) = 174;
|
||||
|
||||
@ -263,10 +432,18 @@ bool Configfile::createConfigFile()
|
||||
gainOffsetSpectralBin2.add("offset", Setting::TypeFloat) = -299.46126663407176;
|
||||
|
||||
|
||||
Setting &ximeadll = root.add("ximeadll", Setting::TypeGroup);
|
||||
ximeadll.add("buffer_policy", Setting::TypeInt) = 0;
|
||||
ximeadll.add("acq_buffer_size", Setting::TypeInt) = 400;
|
||||
|
||||
|
||||
// Write out the new configuration.
|
||||
QString output_file = QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() + "ximea.cfg");
|
||||
QString output_file = "/media/nvme/300TC/config/ximea.cfg";
|
||||
try
|
||||
{
|
||||
QList<QString> fileInfo = getFileInfo(output_file);
|
||||
bool ret = createDir(fileInfo[0]);
|
||||
|
||||
cfg.writeFile(output_file.toStdString().c_str());
|
||||
cerr << "New configuration successfully written to: " << output_file.toStdString().c_str() << endl;
|
||||
|
||||
@ -349,3 +526,295 @@ bool Configfile::updateConfigFile()
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ParameterConfigfile::ParameterConfigfile()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ParameterConfigfile::setConfigfilePath(string configfilePath)
|
||||
{
|
||||
m_configfilePath = configfilePath;
|
||||
}
|
||||
|
||||
bool ParameterConfigfile::isConfigfileExist()
|
||||
{
|
||||
QFileInfo info(QString::fromStdString(m_configfilePath));
|
||||
|
||||
return info.exists();
|
||||
}
|
||||
|
||||
bool ParameterConfigfile::parseConfigfile()
|
||||
{
|
||||
// Read the file. If there is an error, report it and exit.
|
||||
try
|
||||
{
|
||||
cfg.readFile(m_configfilePath);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(const FileIOException &fioex)
|
||||
{
|
||||
std::cerr << "I/O error while reading file." << std::endl;
|
||||
return false;
|
||||
}
|
||||
catch(const ParseException &pex)
|
||||
{
|
||||
std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
|
||||
<< " - " << pex.getError() << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ParameterConfigfile::createConfigFile()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace libconfig;
|
||||
|
||||
Config cfg;
|
||||
|
||||
Setting &root = cfg.getRoot();
|
||||
|
||||
// Add some settings to the configuration.
|
||||
// Setting &SN = root.add("SN", Setting::TypeString) = "0098";
|
||||
// Setting &spatialBin = root.add("spatialBin", Setting::TypeInt) = 2;
|
||||
// Setting &SpectralBin = root.add("spectralBin", Setting::TypeInt) = 2;
|
||||
|
||||
Setting &ximeaParam = root.add("ximeaParam", Setting::TypeGroup);
|
||||
ximeaParam.add("frameRate", Setting::TypeInt) = 100;
|
||||
ximeaParam.add("exposeTime", Setting::TypeFloat) = 10.0;
|
||||
|
||||
|
||||
// Write out the new configuration.
|
||||
try
|
||||
{
|
||||
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
|
||||
bool ret = createDir(fileInfo[0]);
|
||||
|
||||
cfg.writeFile(m_configfilePath.c_str());
|
||||
cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
|
||||
|
||||
}
|
||||
catch(const FileIOException &fioex)
|
||||
{
|
||||
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParameterConfigfile::getFrameRate(int &frameRate)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
try
|
||||
{
|
||||
const Setting &ximeaParam = root["ximeaParam"];
|
||||
frameRate = ximeaParam.lookup("frameRate");
|
||||
|
||||
// std::cout << "ParameterConfigfile::getFrameRate:"<< frameRate<<std::endl;
|
||||
return true;
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No 'frameRate' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ParameterConfigfile::setFrameRate(int frameRate)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
try
|
||||
{
|
||||
Setting &frameRate2 = root["ximeaParam"]["frameRate"];
|
||||
frameRate2 = frameRate;
|
||||
|
||||
writeConfig2File();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No 'frameRate' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ParameterConfigfile::getExposeTime(float &exposeTime)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
try
|
||||
{
|
||||
const Setting &ximeaParam = root["ximeaParam"];
|
||||
exposeTime = ximeaParam.lookup("exposeTime");
|
||||
|
||||
// std::cout << "ParameterConfigfile::getExposeTime"<< exposeTime<<std::endl;
|
||||
return true;
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No 'exposeTime' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ParameterConfigfile::setExposeTime(float exposeTime)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
try
|
||||
{
|
||||
Setting &frameRate2 = root["ximeaParam"]["exposeTime"];
|
||||
frameRate2 = exposeTime;
|
||||
|
||||
writeConfig2File();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No 'exposeTime' setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ParameterConfigfile::writeConfig2File()
|
||||
{
|
||||
try
|
||||
{
|
||||
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
|
||||
bool ret = createDir(fileInfo[0]);
|
||||
|
||||
cfg.writeFile(m_configfilePath.c_str());
|
||||
// cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
|
||||
}
|
||||
catch(const FileIOException &fioex)
|
||||
{
|
||||
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
StateOf300tcConfigfile::StateOf300tcConfigfile()
|
||||
{
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::getIntValue(int &value, string field)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
try
|
||||
{
|
||||
const Setting &ximeaParam = root["ximeaParam"];
|
||||
value = ximeaParam.lookup(field);
|
||||
|
||||
// std::cout << "StateOf300tcConfigfile::getIntValue"<< value<<std::endl;
|
||||
return true;
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::setIntValue(int value, string field)
|
||||
{
|
||||
const Setting& root = cfg.getRoot();
|
||||
try
|
||||
{
|
||||
Setting &frameRate2 = root["ximeaParam"][field];
|
||||
frameRate2 = value;
|
||||
|
||||
writeConfig2File();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch(const SettingNotFoundException &nfex)
|
||||
{
|
||||
cerr << "No setting in configuration file." << endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::createConfigFile()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace libconfig;
|
||||
|
||||
Config cfg;
|
||||
|
||||
Setting &root = cfg.getRoot();
|
||||
|
||||
// Add some settings to the configuration.
|
||||
// Setting &SN = root.add("SN", Setting::TypeString) = "0098";
|
||||
// Setting &spatialBin = root.add("spatialBin", Setting::TypeInt) = 2;
|
||||
// Setting &SpectralBin = root.add("spectralBin", Setting::TypeInt) = 2;
|
||||
|
||||
Setting &ximeaParam = root.add("ximeaParam", Setting::TypeGroup);
|
||||
ximeaParam.add("sbgState", Setting::TypeInt) = 0;
|
||||
ximeaParam.add("sbgSolutionMode", Setting::TypeInt) = 0;
|
||||
ximeaParam.add("ximeaState", Setting::TypeInt) = 100;
|
||||
ximeaParam.add("frameRate", Setting::TypeInt) = 0;
|
||||
ximeaParam.add("exposeTime", Setting::TypeFloat) = 0.0;
|
||||
ximeaParam.add("exposeMaxValueOfOneFrame", Setting::TypeInt) = 0;
|
||||
|
||||
|
||||
// Write out the new configuration.
|
||||
try
|
||||
{
|
||||
QList<QString> fileInfo = getFileInfo(QString::fromStdString(m_configfilePath));
|
||||
bool ret = createDir(fileInfo[0]);
|
||||
|
||||
cfg.writeFile(m_configfilePath.c_str());
|
||||
cerr << "New configuration successfully written to: " << m_configfilePath.c_str() << endl;
|
||||
|
||||
}
|
||||
catch(const FileIOException &fioex)
|
||||
{
|
||||
cerr << "I/O error while writing configuration file: " << m_configfilePath.c_str() << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::getSbgState(int &sbgState)
|
||||
{
|
||||
return getIntValue(sbgState,"sbgState");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::setSbgState(int sbgState)
|
||||
{
|
||||
return setIntValue(sbgState,"sbgState");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::getSbgSolutionMode(int &sbgSolutionMode)
|
||||
{
|
||||
return getIntValue(sbgSolutionMode,"sbgSolutionMode");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::setSbgSolutionMode(int sbgSolutionMode)
|
||||
{
|
||||
return setIntValue(sbgSolutionMode,"sbgSolutionMode");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::getXimeaState(int &ximeaState)
|
||||
{
|
||||
return getIntValue(ximeaState,"ximeaState");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::setXimeaState(int ximeaState)
|
||||
{
|
||||
return setIntValue(ximeaState,"ximeaState");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::getExposeMaxValueOfOneFrame(int &exposeMaxValueOfOneFrame)
|
||||
{
|
||||
return getIntValue(exposeMaxValueOfOneFrame,"exposeMaxValueOfOneFrame");
|
||||
}
|
||||
|
||||
bool StateOf300tcConfigfile::setExposeMaxValueOfOneFrame(int exposeMaxValueOfOneFrame)
|
||||
{
|
||||
return setIntValue(exposeMaxValueOfOneFrame,"exposeMaxValueOfOneFrame");
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::cout<<"ximeaAirborneSystem 版本:"<< "41." <<std::endl;
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
//UdpServer* x=new UdpServer();
|
||||
|
307
Source_Files/rgbImage.cpp
Normal file
307
Source_Files/rgbImage.cpp
Normal file
@ -0,0 +1,307 @@
|
||||
//
|
||||
// Created by tangchao on 2022/12/24.
|
||||
//
|
||||
|
||||
#include "../Header_Files/rgbImage.h"
|
||||
|
||||
rgbImage::rgbImage(QWidget* pParent)
|
||||
{
|
||||
m_QRgbImage = nullptr;
|
||||
m_matRgbImage = nullptr;
|
||||
m_matFocusGrayImage = nullptr;
|
||||
m_qimageFocusGrayImage = nullptr;
|
||||
|
||||
m_iRedBandNumber = 0;
|
||||
m_iGreenBandNumber = 0;
|
||||
m_iBlueBandNumber = 0;
|
||||
}
|
||||
|
||||
rgbImage::~rgbImage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void rgbImage::SetRgbBandNumber(int redBandNumber, int greenBandNumber, int blueBandNumber)
|
||||
{
|
||||
m_iRedBandNumber = redBandNumber;
|
||||
m_iGreenBandNumber = greenBandNumber;
|
||||
m_iBlueBandNumber = blueBandNumber;
|
||||
|
||||
// std::cout<<"rgbImage::SetRgbBandNumber,红波段的波段号:"<< redBandNumber <<std::endl;
|
||||
// std::cout<<"rgbImage::SetRgbBandNumber,绿波段的波段号:"<< greenBandNumber <<std::endl;
|
||||
// std::cout<<"rgbImage::SetRgbBandNumber,蓝波段的波段号:"<< blueBandNumber <<std::endl;
|
||||
}
|
||||
|
||||
void rgbImage::SetRgbImageWidthAndHeight(int BandCount, int Width, int height)
|
||||
{
|
||||
using namespace cv;
|
||||
|
||||
if (m_QRgbImage != nullptr)
|
||||
{
|
||||
delete m_QRgbImage;//有问题????????????????????????????????????????????????
|
||||
}
|
||||
//m_QRgbImage = new QImage(Width, height, QImage::Format_RGB888);
|
||||
|
||||
|
||||
if (m_matRgbImage != nullptr)
|
||||
{
|
||||
delete m_matRgbImage;
|
||||
}
|
||||
m_matRgbImage = new Mat(height, Width, CV_8UC3, Scalar(0, 0, 0));
|
||||
|
||||
// int codec = VideoWriter::fourcc('H', '2', '6', '4'); // select desired codec (must be available at runtime)
|
||||
// double fps = 20.0;// framerate of the created video stream
|
||||
// std::string filename = "appsrc ! autovideoconvert ! filesink location=/media/nvme/live.mp4";//https://blog.csdn.net/ancientapesman/article/details/117324638
|
||||
//// std::string filename = "/media/nvme/live.mp4";
|
||||
// auto ddddd=m_matRgbImage->size();
|
||||
// m_VideoWriter.open(filename, codec, fps, Size(20, 1368), true);
|
||||
|
||||
// VideoWriter video("test.avi", CV_FOURCC('M', 'J', 'P', 'G'), 25.0, Size(640, 480));
|
||||
|
||||
// m_frame_writer = cvCreateVideoWriter("/media/nvme/delete/live.avi", cv::VideoWriter::fourcc('M', 'J', 'P', 'G'), 20.0, Size(688, 688), false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_qimageFocusGrayImage == nullptr)
|
||||
{
|
||||
m_qimageFocusGrayImage = new QImage(Width, BandCount, QImage::Format_RGB32);
|
||||
}
|
||||
|
||||
|
||||
if (m_matFocusGrayImage == nullptr)
|
||||
{
|
||||
m_matFocusGrayImage = new Mat(BandCount, Width, CV_16U, Scalar(0));
|
||||
|
||||
//cv::Mat matAdjustPreview = Mat::zeros(BandCount, Width, CV_16U);
|
||||
}
|
||||
|
||||
//cv::Mat matAdjustPreview = Mat::zeros(BandCount, Width, CV_16U);
|
||||
//m_matFocusGrayImage = matAdjustPreview;
|
||||
|
||||
std::cout << "高光谱rgb图像设置高度:" << height << std::endl;
|
||||
|
||||
m_iFrameCounter = 0;//每次都重置为0
|
||||
m_iSampleNumber = Width;
|
||||
m_iBandNumber = BandCount;
|
||||
m_iFrameNumber = height;
|
||||
|
||||
//std::cout << "rgb影像内存地址为:" << m_QRgbImage << std::endl;
|
||||
}
|
||||
|
||||
void rgbImage::FillOnerowofRgbImage(cv::Mat * matRgbImage, int rowNumber, unsigned short *datacube)
|
||||
{
|
||||
//方式1:逐像素修改
|
||||
// unsigned short r, g, b;
|
||||
// for (int j = 0; j < m_iSampleNumber; j++)
|
||||
// {
|
||||
// //取值:一帧影像中,从左到右的rgb像元值
|
||||
// r = *(datacube + m_iRedBandNumber * m_iSampleNumber + j)*255/4096;
|
||||
// g = *(datacube + m_iGreenBandNumber * m_iSampleNumber + j)*255/4096;
|
||||
// b = *(datacube + m_iBlueBandNumber * m_iSampleNumber + j)*255/4096;
|
||||
//
|
||||
//// r = *(datacube + m_iRedBandNumber * m_iSampleNumber + j);
|
||||
//// g = *(datacube + m_iGreenBandNumber * m_iSampleNumber + j);
|
||||
//// b = *(datacube + m_iBlueBandNumber * m_iSampleNumber + j);
|
||||
//
|
||||
// //将像元值赋值到cv::Mat中,操作像元值:https://zhuanlan.zhihu.com/p/51842288
|
||||
// //int dataType = m_matRgbImage->type();//当数据类型为CV_16UC3时,返回18
|
||||
// //std::cout << "m_matRgbImage数据类型为:" << dataType << std::endl;
|
||||
// if (matRgbImage->type() == CV_8UC3)
|
||||
// {
|
||||
//// std::cout << "操作像素值!" << std::endl;
|
||||
// matRgbImage->at<cv::Vec3b>(rowNumber, j)[2] = r;
|
||||
// matRgbImage->at<cv::Vec3b>(rowNumber, j)[1] = g;
|
||||
// matRgbImage->at<cv::Vec3b>(rowNumber, j)[0] = b;
|
||||
//
|
||||
//// QString savePath_cv = "/media/nvme/delete/" + QString::number(m_iFrameCounter) + "_cv.png";
|
||||
//// cv::imwrite(savePath_cv.toStdString(), *matRgbImage);
|
||||
// }
|
||||
//
|
||||
// int column = 800;
|
||||
// if(j == column)
|
||||
// {
|
||||
// std::cout << "行:" << rowNumber << "提取:第 " << column << " 列的 r g b 分别为 " << r << " " << g << " " << b << std::endl;
|
||||
// std::cout << "mat:第 " << column << " 列的 r g b 分别为 " << (unsigned short)matRgbImage->at<cv::Vec3b>(rowNumber, j)[2] << " " << (unsigned short)matRgbImage->at<cv::Vec3b>(rowNumber, j)[1] << " " << (unsigned short)matRgbImage->at<cv::Vec3b>(rowNumber, j)[0] << std::endl;
|
||||
// }
|
||||
// }
|
||||
|
||||
//方式2:通过指针操作,更快
|
||||
unsigned short r, g, b;
|
||||
const int cols = matRgbImage->cols;
|
||||
const int step = matRgbImage->channels();
|
||||
|
||||
unsigned char *p_row0_b = matRgbImage->ptr(rowNumber);
|
||||
unsigned char *p_row0_g = matRgbImage->ptr(rowNumber) + 1;
|
||||
unsigned char *p_row0_r = matRgbImage->ptr(rowNumber) + 2;
|
||||
|
||||
for (int j = 0; j < m_iSampleNumber; j++)
|
||||
{
|
||||
//取值:一帧影像中,从左到右的rgb像元值,线性拉伸
|
||||
r = *(datacube + m_iRedBandNumber * m_iSampleNumber + j)*255/4096;
|
||||
g = *(datacube + m_iGreenBandNumber * m_iSampleNumber + j)*255/4096;
|
||||
b = *(datacube + m_iBlueBandNumber * m_iSampleNumber + j)*255/4096;
|
||||
|
||||
*p_row0_b = b;
|
||||
*p_row0_g = g;
|
||||
*p_row0_r = r;
|
||||
|
||||
// int column = 800;
|
||||
// if(j == column)
|
||||
// {
|
||||
// std::cout << "行:" << rowNumber << "提取:第 " << column << " 列的 r g b 分别为 " << r << " " << g << " " << b << std::endl;
|
||||
//// std::cout << "修改后" << rowNumber << "提取:第 " << column << " 列的 r g b 分别为 " << (unsigned short)*p_row0_r << " " << (unsigned short)*p_row0_g << " " << (unsigned short)*p_row0_b << std::endl;
|
||||
//// std::cout << "mat:第 " << column << " 列的 r g b 分别为 " << (unsigned short)matRgbImage->at<cv::Vec3b>(rowNumber, j)[2] << " " << (unsigned short)matRgbImage->at<cv::Vec3b>(rowNumber, j)[1] << " " << (unsigned short)matRgbImage->at<cv::Vec3b>(rowNumber, j)[0] << std::endl;
|
||||
// }
|
||||
|
||||
p_row0_b += step;
|
||||
p_row0_g += step;
|
||||
p_row0_r += step;
|
||||
}
|
||||
|
||||
//方式3:通过内存拷贝快速提取rgb
|
||||
// if (matRgbImage->isContinuous())// check mat is continuous or not
|
||||
// matRgbImage->reshape(1, matRgbImage->rows * matRgbImage->cols).col(0).setTo(Scalar(value));
|
||||
// else
|
||||
// {
|
||||
// for (int i = 0; i < matRgbImage->rows; i++)
|
||||
// matRgbImage->row(i).reshape(1, matRgbImage->cols).col(0).setTo(Scalar(value));
|
||||
// }
|
||||
}
|
||||
|
||||
QImage rgbImage::Mat2QImage(cv::Mat cvImg)//https://www.cnblogs.com/annt/p/ant003.html
|
||||
{
|
||||
QImage qImg;
|
||||
if (cvImg.channels() == 3)//3 channels color image
|
||||
{
|
||||
cv::cvtColor(cvImg, cvImg, CV_BGR2RGB);
|
||||
qImg = QImage((const unsigned char*)(cvImg.data),
|
||||
cvImg.cols, cvImg.rows,
|
||||
cvImg.cols*cvImg.channels(),
|
||||
QImage::Format_RGB888);
|
||||
}
|
||||
else if (cvImg.channels() == 1)//grayscale image
|
||||
{
|
||||
qImg = QImage((const unsigned char*)(cvImg.data),
|
||||
cvImg.cols, cvImg.rows,
|
||||
cvImg.cols*cvImg.channels(),
|
||||
QImage::Format_Indexed8);
|
||||
}
|
||||
else
|
||||
{
|
||||
qImg = QImage((const unsigned char*)(cvImg.data),
|
||||
cvImg.cols, cvImg.rows,
|
||||
cvImg.cols*cvImg.channels(),
|
||||
QImage::Format_RGB888);
|
||||
}
|
||||
|
||||
return qImg;
|
||||
}
|
||||
|
||||
void rgbImage::FillRgbImage(unsigned short *datacube)
|
||||
{
|
||||
//从第二行开始,向下移动一行,https://blog.csdn.net/u014686356/article/details/65937750
|
||||
// m_matRgbImage->rowRange(0, m_matRgbImage->rows - 1).copyTo(m_matRgbImage->rowRange(1, m_matRgbImage->rows));//经tc验证:此行代码工作异常,为啥不加.clone()就异常??????
|
||||
// m_matRgbImage->rowRange(0, m_matRgbImage->rows - 1).clone().copyTo(m_matRgbImage->rowRange(1, m_matRgbImage->rows));//此方式,ximea帧率130hz,1min左右就出现漏帧
|
||||
|
||||
// cv::Mat upperPart = m_matRgbImage->rowRange(0, m_matRgbImage->rows - 1).clone();//此方式,ximea帧率130hz,1min左右就出现漏帧
|
||||
// upperPart.copyTo(m_matRgbImage->rowRange(1, m_matRgbImage->rows));
|
||||
|
||||
for (int i = m_matRgbImage->rows - 2; i >= 0; --i)//此方式,ximea帧率130hz,4.5min左右出现漏帧 → 此方式效率最高
|
||||
{
|
||||
m_matRgbImage->row(i).copyTo(m_matRgbImage->row(i+1));
|
||||
}
|
||||
|
||||
FillOnerowofRgbImage(m_matRgbImage, 0, datacube);
|
||||
|
||||
// m_Qphoto = Mat2QImage(*m_matRgbImage);
|
||||
|
||||
//保存rgb图片
|
||||
// if (m_iFrameCounter % m_iFramerate == 0 || m_iFrameCounter == m_iFrameNumber - 1)
|
||||
// {
|
||||
//// QString savePath = "/media/nvme/delete/" + QString::number(m_iFrameCounter) + "_qt.jpg";
|
||||
//// m_Qphoto.save(savePath);
|
||||
//
|
||||
// QString savePath_cv = "/media/nvme/delete/" + QString::number(m_iFrameCounter) + "_cv.jpg";
|
||||
// cv::imwrite(savePath_cv.toStdString(), *m_matRgbImage);
|
||||
// }
|
||||
// m_VideoWriter.write(*m_matRgbImage);
|
||||
// std::string rgbFilePathNoStrech = "/media/nvme/delete/" + std::to_string(m_iFrameCounter) + "ctmp_image_no_strech.png";
|
||||
// cv::imwrite(rgbFilePathNoStrech, *m_matRgbImage);
|
||||
|
||||
m_iFrameCounter++;
|
||||
}
|
||||
|
||||
void rgbImage::FillFocusGrayImage(unsigned short * datacube)
|
||||
{
|
||||
int rowCount = m_matFocusGrayImage->rows;
|
||||
int colCount = m_matFocusGrayImage->cols;
|
||||
for (unsigned short i = 0; i < m_matFocusGrayImage->rows; i++)
|
||||
{
|
||||
for (unsigned short j = 0; j < m_matFocusGrayImage->cols; j++)
|
||||
{
|
||||
//m_matFocusGrayImage->at<ushort>(i, j) = *(datacube + m_matFocusGrayImage->cols*i + j);
|
||||
m_matFocusGrayImage->at<ushort>(i, j) = datacube[m_matFocusGrayImage->cols*i + j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//int rowCount = m_matFocusGrayImage.rows;
|
||||
//int colCount = m_matFocusGrayImage.cols;
|
||||
////memcpy(m_matFocusGrayImage.data, datacube, rowCount*colCount);
|
||||
//for (unsigned short i = 0; i < m_matFocusGrayImage.rows; i++)
|
||||
//{
|
||||
// for (unsigned short j = 0; j < m_matFocusGrayImage.cols; j++)
|
||||
// {
|
||||
// m_matFocusGrayImage.at<ushort>(i, j) = *(datacube + m_matFocusGrayImage.cols*i + j);
|
||||
// //m_matFocusGrayImage.at<ushort>(i, j) = datacube[colCount*i + j];
|
||||
// }
|
||||
//}
|
||||
|
||||
//将mat保存成文件
|
||||
//cv::imwrite("D:/delete/2222222222/test.bmp", m_matFocusGrayImage);
|
||||
}
|
||||
|
||||
void rgbImage::FillFocusGrayQImage(unsigned short * datacube)
|
||||
{
|
||||
float two_eight = pow(2.0, 8);
|
||||
float two_sixteen = pow(2.0, 12);
|
||||
|
||||
int width = m_qimageFocusGrayImage->width();
|
||||
int height = m_qimageFocusGrayImage->height();
|
||||
for (unsigned short i = 0; i < height; i++)
|
||||
{
|
||||
for (unsigned short j = 0; j < width; j++)
|
||||
{
|
||||
//uint tmp = (two_eight* *(datacube + width * i + j)) / two_sixteen;
|
||||
uint tmp = (two_eight* datacube[width*i + j]) / two_sixteen;
|
||||
//uint tmp = datacube[width*i + j];
|
||||
|
||||
|
||||
//m_qimageFocusGrayImage->setPixel(j, i, tmp);
|
||||
m_qimageFocusGrayImage->setPixel(j, i, qRgb((unsigned char)tmp, (unsigned char)tmp, (unsigned char)tmp));
|
||||
}
|
||||
}
|
||||
|
||||
m_qimageFocusGrayImage->save("D:/delete/2222222222/test.bmp");
|
||||
|
||||
|
||||
|
||||
|
||||
/*float two_eight = pow(2.0, 8);
|
||||
float two_sixteen = pow(2.0, 16);
|
||||
QImage *qi = new QImage(imwidth, imheight, QImage::Format_RGB32);
|
||||
for (int i = 0; i < imheight; i++)
|
||||
{
|
||||
for (int j = 0; j < imwidth; j++)
|
||||
{
|
||||
floatData[i*imwidth + j] = (two_eight* floatData[i*imwidth + j]) / two_sixteen;
|
||||
qi->setPixel(j, i, qRgb((unsigned char)floatData[i*imwidth + j], (unsigned char)floatData[i*imwidth + j], (unsigned char)floatData[i*imwidth + j]));
|
||||
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
@ -53,7 +53,7 @@ void sbgtc::SbgRecorder::openSerialPort()
|
||||
}
|
||||
|
||||
// QString portname = "sbg_serial_port";
|
||||
QString portname = "ttyUSB2";
|
||||
QString portname = "ttyUSB0";
|
||||
|
||||
m_serial->setPortName(portname);
|
||||
m_serial->open(QIODevice::ReadWrite);
|
||||
@ -608,76 +608,51 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
||||
//判断模式是否为: NAV_POSITION
|
||||
if(receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_EKF_EULER)
|
||||
{
|
||||
m_iSolutionModeCounter++;//
|
||||
m_iSolutionModeCounter++;
|
||||
|
||||
uint32_t status=logData.ekfEulerData.status;
|
||||
uint32_t mode=status>>24;//?????????????????????????????????????
|
||||
// uint32_t mode=status;//这是错的
|
||||
uint32_t mode=status & 0xf;
|
||||
|
||||
//一秒钟发射一次mode
|
||||
if(m_iSolutionModeCounter%200 == 0)
|
||||
{
|
||||
emit sbgSolutionModeSignal(mode);
|
||||
// std::cout << "logData.ekfEulerData.status: " << status << std::endl;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case SBG_ECOM_SOL_MODE_UNINITIALIZED:
|
||||
std::cout<<"此刻模式为: "<<"UNINITIALIZED"<<std::endl;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_VERTICAL_GYRO:
|
||||
std::cout<<"此刻模式为: "<<"VERTICAL_GYRO"<<std::endl;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_AHRS:
|
||||
std::cout<<"此刻模式为: "<<"AHRS"<<std::endl;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_NAV_VELOCITY:
|
||||
std::cout<<"此刻模式为: "<<"NAV_VELOCITY"<<std::endl;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_NAV_POSITION:
|
||||
std::cout<<"此刻模式为: "<<"NAV_POSITION"<<std::endl;
|
||||
switch (mode) {
|
||||
case SBG_ECOM_SOL_MODE_UNINITIALIZED:
|
||||
// std::cout << "此刻模式为: " << "UNINITIALIZED" << std::endl;
|
||||
m_bIsNAV_POSITION_MODE = false;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_VERTICAL_GYRO:
|
||||
// std::cout << "此刻模式为: " << "VERTICAL_GYRO" << std::endl;
|
||||
m_bIsNAV_POSITION_MODE = false;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_AHRS:
|
||||
// std::cout << "此刻模式为: " << "AHRS" << std::endl;
|
||||
m_bIsNAV_POSITION_MODE = false;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_NAV_VELOCITY:
|
||||
// std::cout << "此刻模式为: " << "NAV_VELOCITY" << std::endl;
|
||||
m_bIsNAV_POSITION_MODE = false;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_NAV_POSITION:
|
||||
// std::cout << "此刻模式为: " << "NAV_POSITION" << std::endl;
|
||||
m_bIsNAV_POSITION_MODE = true;
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case SBG_ECOM_SOL_MODE_UNINITIALIZED:
|
||||
// std::cout<<"此刻模式为: "<<"UNINITIALIZED"<<std::endl;
|
||||
m_bIsNAV_POSITION_MODE=false;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_VERTICAL_GYRO:
|
||||
// std::cout<<"此刻模式为: "<<"VERTICAL_GYRO"<<std::endl;
|
||||
m_bIsNAV_POSITION_MODE=false;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_AHRS:
|
||||
// std::cout<<"此刻模式为: "<<"AHRS"<<std::endl;
|
||||
m_bIsNAV_POSITION_MODE=false;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_NAV_VELOCITY:
|
||||
// std::cout<<"此刻模式为: "<<"NAV_VELOCITY"<<std::endl;
|
||||
m_bIsNAV_POSITION_MODE=false;
|
||||
break;
|
||||
case SBG_ECOM_SOL_MODE_NAV_POSITION:
|
||||
// std::cout<<"此刻模式为: "<<"NAV_POSITION"<<std::endl;
|
||||
m_bIsNAV_POSITION_MODE=true;
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_GPS1_POS)
|
||||
{
|
||||
// std::cout<<"纬度精度为:"<<logData.gpsPosData.latitudeAccuracy<<std::endl;
|
||||
|
||||
float maximal=0;
|
||||
float latitudeAccuracy=logData.gpsPosData.latitudeAccuracy;
|
||||
float longitudeAccuracy=logData.gpsPosData.longitudeAccuracy;
|
||||
float altitudeAccuracy=logData.gpsPosData.altitudeAccuracy;
|
||||
|
||||
int satelliteCounter=(int)logData.gpsPosData.numSvUsed;
|
||||
|
||||
if(latitudeAccuracy<longitudeAccuracy)
|
||||
maximal = longitudeAccuracy;
|
||||
@ -687,7 +662,14 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
||||
if(maximal<altitudeAccuracy)
|
||||
maximal = altitudeAccuracy;
|
||||
|
||||
emit sbgAccuracySignal(static_cast<int>(maximal));
|
||||
// std::cout<<"纬度精度为:"<<maximal<<std::endl;
|
||||
// std::cout<<"numSvUsed:"<<satelliteCounter<<std::endl;
|
||||
//
|
||||
// std::cout<<"latitude:"<<logData.gpsPosData.latitude<<std::endl;
|
||||
// std::cout<<"longitude:"<<logData.gpsPosData.longitude<<std::endl;
|
||||
// std::cout<<"altitude:"<<logData.gpsPosData.altitude<<std::endl;
|
||||
|
||||
emit sbgAccuracySignal(static_cast<int>(maximal), satelliteCounter);
|
||||
|
||||
if(maximal<7)
|
||||
{
|
||||
@ -710,15 +692,10 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
||||
char setGpsTimeCommand[256];
|
||||
sprintf(setGpsTimeCommand,"date --set=\"%d%02d%02d %02d:%02d:%02d\"",year,month,day,hour,minute,second);//02中的2代表2位数字,0代表以0补全
|
||||
|
||||
system(setGpsTimeCommand);//
|
||||
// system(setGpsTimeCommand);
|
||||
|
||||
m_bIsSyncSystemTimeBaseGpstime=true;
|
||||
}
|
||||
else if(receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_EKF_EULER)
|
||||
{
|
||||
// std::cout<<"1111111111111"<<"UTC time:"<<(int)logData.utcData.year<<","<<(int)logData.utcData.month<<","<<(int)logData.utcData.day<<","<<(int)logData.utcData.hour<<","<<(int)logData.utcData.minute<<","<<(int)(int)logData.utcData.second<<std::endl;
|
||||
// std::cout<<"receivedMsg:"<<(int)receivedMsg<<std::endl;
|
||||
}
|
||||
else if(receivedMsgClass!=SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_EKF_QUAT)
|
||||
{
|
||||
//std::cout<<"1111111111111------"<<"UTC time:"<<(int)logData.utcData.year<<","<<(int)logData.utcData.month<<","<<(int)logData.utcData.day<<","<<(int)logData.utcData.hour<<","<<(int)logData.utcData.minute<<","<<(int)(int)logData.utcData.second<<std::endl;
|
||||
@ -731,7 +708,7 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
||||
|
||||
|
||||
//控制开始采集高光谱影像,m_bIsNAV_POSITION_MODE &&
|
||||
if(m_bIsRecordHyperspecatralImage && m_bIsSyncSystemTimeBaseGpstime && receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_UTC_TIME)
|
||||
if(m_bIsRecordHyperspecatralImage && m_bIsSyncSystemTimeBaseGpstime && m_bIsNAV_POSITION_MODE && receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_UTC_TIME)
|
||||
{
|
||||
m_baseFileName=getFileNameBaseOnTime();
|
||||
emit sbgReady(calculateTimeDifferenceBetweenSystemAndSbg(logData),m_baseFileName);
|
||||
@ -793,7 +770,7 @@ void sbgtc::SbgRecorder::startRecordSbg()
|
||||
|
||||
m_baseFileName=getFileNameBaseOnTime();
|
||||
|
||||
QString sbgFileName=m_baseFileName+".sbg";
|
||||
QString sbgFileName=m_baseFileName+".bin";
|
||||
|
||||
FILE * fileHandle=fopen(sbgFileName.toStdString().c_str(),"w+b");
|
||||
|
||||
@ -802,7 +779,7 @@ void sbgtc::SbgRecorder::startRecordSbg()
|
||||
while (m_bRecordControl)
|
||||
{
|
||||
//std::cout<<"SbgRecorder::startRecordSbg--------------:"<<std::endl;
|
||||
if(m_serial->waitForReadyRead())
|
||||
if(m_serial->waitForReadyRead(30000))
|
||||
{
|
||||
//requestData.resize(m_serial->size());
|
||||
requestData = m_serial->readAll();
|
||||
|
@ -8,16 +8,16 @@ UdpServer::UdpServer()
|
||||
m_udpSocket->bind(45454, QUdpSocket::ShareAddress);
|
||||
connect(m_udpSocket, SIGNAL(readyRead()),this, SLOT(processPendingDatagrams()));
|
||||
|
||||
m_RecordThread=new QThread();
|
||||
m_imager=new XimeaImager();
|
||||
m_imager->moveToThread(m_RecordThread);
|
||||
m_RecordThread->start(QThread::HighestPriority);
|
||||
|
||||
m_RecordSbgThread=new QThread();
|
||||
m_sbgRecorder=new sbgtc::SbgRecorder();
|
||||
m_sbgRecorder->moveToThread(m_RecordSbgThread);
|
||||
m_RecordSbgThread->start();
|
||||
|
||||
m_RecordThread=new QThread();
|
||||
m_imager=new XimeaImager();
|
||||
m_imager->moveToThread(m_RecordThread);
|
||||
m_RecordThread->start();
|
||||
|
||||
m_CopyFileThread=new QThread();
|
||||
m_copyFile=new FileOperation();
|
||||
m_copyFile->moveToThread(m_CopyFileThread);
|
||||
@ -47,21 +47,45 @@ UdpServer::UdpServer()
|
||||
connect(m_sbgRecorder, SIGNAL(serialPortStatus(int)),this, SLOT(sendSerialPortStatus(int)));
|
||||
|
||||
connect(m_sbgRecorder, SIGNAL(sbgSolutionModeSignal(int)),this, SLOT(sendSbgSolutionModeState(int)));
|
||||
connect(m_sbgRecorder, SIGNAL(sbgAccuracySignal(int)),this, SLOT(sendSbgAccuracyState(int)));
|
||||
connect(m_sbgRecorder, SIGNAL(sbgAccuracySignal(int,int)),this, SLOT(sendSbgAccuracyState(int,int)));
|
||||
|
||||
connect(m_imager, SIGNAL(ximeaImageStatus(int)),this, SLOT(sendXimeaImageStatus(int)));
|
||||
connect(m_imager, SIGNAL(autoExposeMaxValueOfOneFrame(int, double)),this, SLOT(sendXimeaAutoExposeMaxValueOfOneFrame(int, double)));
|
||||
connect(m_imager, SIGNAL(binSignal(int, int)),this, SLOT(sendXimeaBinState(int, int)));
|
||||
connect(m_imager, SIGNAL(frameRateSignal(double)),this, SLOT(sendXimeaImageFrameRate(double)));
|
||||
connect(m_copyFile, SIGNAL(copyFileStatus(int)),this, SLOT(sendCopyFileStatus(int)));
|
||||
|
||||
QString ximeaParamCfgFile = "/media/nvme/300TC/config/StateOf300tc.cfg";
|
||||
stateOf300tc.setConfigfilePath(ximeaParamCfgFile.toStdString());
|
||||
if(!stateOf300tc.isConfigfileExist())
|
||||
stateOf300tc.createConfigFile();
|
||||
stateOf300tc.parseConfigfile();
|
||||
|
||||
stateOf300tc.setSbgState(0);
|
||||
stateOf300tc.setSbgSolutionMode(0);
|
||||
stateOf300tc.setXimeaState(100);
|
||||
stateOf300tc.setFrameRate(0);
|
||||
stateOf300tc.setExposeTime(0);
|
||||
stateOf300tc.setExposeMaxValueOfOneFrame(0);
|
||||
|
||||
//当软件不正常关闭并且重启后,通知其他psdk程序
|
||||
m_clientIpAddress=QHostAddress(QHostAddress::LocalHost);
|
||||
sendSerialPortStatus(0);
|
||||
sendXimeaImageStatus(0);
|
||||
sendXimeaImageStatus(100);
|
||||
sendCopyFileStatus(0);
|
||||
|
||||
system("sudo gpio write 10 0");
|
||||
|
||||
m_recordTempThread=new QThread();
|
||||
m_300tcTemperature = new Record300TcTemperature();
|
||||
m_300tcTemperature->moveToThread(m_recordTempThread);
|
||||
m_recordTempThread->start();
|
||||
connect(this, SIGNAL(record300tcTemperatureSignal(QString)),m_300tcTemperature, SLOT(recordTemperature(QString)));
|
||||
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
QString Temperature300tcCSVPath = QDir::cleanPath(QString::fromStdString("/media/nvme/300TC/programRunLog/300tcTemperature") + QDir::separator() + "300tcTemperature_" + currentTime + ".csv");
|
||||
emit record300tcTemperatureSignal(Temperature300tcCSVPath);
|
||||
|
||||
std::cout<<"UdpServer::UdpServer--------:System ready!"<<std::endl;
|
||||
}
|
||||
@ -99,7 +123,7 @@ void UdpServer::processPendingDatagrams()
|
||||
case 2://关闭系统:关闭相机和sbg串口,关闭软件
|
||||
{
|
||||
std::cout<<"2代表关闭系统!"<<std::endl;
|
||||
|
||||
m_300tcTemperature->stopRecordTemperature();
|
||||
|
||||
if(m_sbgRecorder->getSbgState()>=1)
|
||||
{
|
||||
@ -122,26 +146,19 @@ void UdpServer::processPendingDatagrams()
|
||||
}
|
||||
case 3://系统开始采集高光谱影像
|
||||
{
|
||||
//emit startRecordHyperspectralSignal();//真实的影像开始采集通过惯导中的信号(sbgReady)触发
|
||||
m_sbgRecorder->startRecordHyperspectral();
|
||||
|
||||
// if(m_sbgRecorder->getSbgState()==2)//开始采集前还需要判断相机的状态??????????????????????????????????????????
|
||||
// {
|
||||
|
||||
// }
|
||||
// else if(m_sbgRecorder->getSbgState()==3)
|
||||
// {
|
||||
// std::cout<<"系统已经开始采集!"<<std::endl;
|
||||
// }
|
||||
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=103)
|
||||
{
|
||||
std::cout<<"3代表系统开始采集高光谱影像!"<<std::endl;
|
||||
m_sbgRecorder->startRecordHyperspectral();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 4://系统停止采集高光谱影像
|
||||
{
|
||||
std::cout<<"4代表系统停止采集高光谱影像!"<<std::endl;
|
||||
|
||||
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=104)
|
||||
{
|
||||
std::cout<<"4代表系统停止采集高光谱影像!"<<std::endl;
|
||||
m_imager->stopRecord();
|
||||
}
|
||||
|
||||
@ -169,17 +186,11 @@ void UdpServer::processPendingDatagrams()
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
if(datagramList[1].toInt()==1)
|
||||
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=103)
|
||||
{
|
||||
std::cout<<"拷贝数据!"<<std::endl;
|
||||
|
||||
emit startCopyFileSignal();
|
||||
}
|
||||
else if(datagramList[1].toInt()==0)
|
||||
{
|
||||
std::cout<<"删除数据!"<<std::endl;
|
||||
|
||||
emit startDeleteFileSignal();
|
||||
float time = datagramList[1].toFloat();//μs
|
||||
m_imager->wrapSetExposureTime(time);
|
||||
std::cout<<"7,手动设置曝光时间为:" << time <<std::endl;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -207,8 +218,30 @@ void UdpServer::processPendingDatagrams()
|
||||
|
||||
break;
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
std::cout<<"10代表!"<<std::endl;
|
||||
|
||||
int sbgState,sbgSolutionMode,ximeaState,frameRate,exposeMaxValueOfOneFrame;
|
||||
float exposeTime;
|
||||
|
||||
stateOf300tc.getSbgState(sbgState);
|
||||
stateOf300tc.getSbgSolutionMode(sbgSolutionMode);
|
||||
stateOf300tc.getXimeaState(ximeaState);
|
||||
stateOf300tc.getFrameRate(frameRate);
|
||||
stateOf300tc.getExposeTime(exposeTime);
|
||||
stateOf300tc.getExposeMaxValueOfOneFrame(exposeMaxValueOfOneFrame);
|
||||
|
||||
sendSerialPortStatus(sbgState);
|
||||
sendSbgSolutionModeState(sbgSolutionMode);
|
||||
sendXimeaImageStatus(ximeaState);
|
||||
sendXimeaAutoExposeMaxValueOfOneFrame(exposeMaxValueOfOneFrame, exposeTime);
|
||||
sendXimeaImageFrameRate(frameRate);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
std::cout<<">=9没有意义!"<<std::endl;
|
||||
std::cout<<">=11没有意义!"<<std::endl;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -260,9 +293,9 @@ void UdpServer::sender(int status)
|
||||
|
||||
void UdpServer::sendSerialPortStatus(int serialPortStatus)
|
||||
{
|
||||
std::cout<<"UdpServer::sendSerialPortStatus---------------------:"<< serialPortStatus <<std::endl;
|
||||
// std::cout<<"UdpServer::sendSerialPortStatus---------------------:"<< serialPortStatus <<std::endl;
|
||||
|
||||
std::cout<<"UdpServer::sendSerialPortStatus---------------------:"<< m_clientIpAddress.AnyIPv4 <<std::endl;
|
||||
// std::cout<<"UdpServer::sendSerialPortStatus---------------------:"<< m_clientIpAddress.AnyIPv4 <<std::endl;
|
||||
|
||||
QByteArray datagram2send;
|
||||
|
||||
@ -270,11 +303,13 @@ void UdpServer::sendSerialPortStatus(int serialPortStatus)
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
|
||||
stateOf300tc.setSbgState(serialPortStatus);
|
||||
}
|
||||
|
||||
void UdpServer::sendSbgSolutionModeState(int SolutionMode)
|
||||
{
|
||||
std::cout<<"UdpServer::sendSbgSolutionModeState---------------------:"<< SolutionMode <<std::endl;
|
||||
// std::cout<<"UdpServer::sendSbgSolutionModeState---------------------:"<< SolutionMode <<std::endl;
|
||||
|
||||
QByteArray datagram2send;
|
||||
|
||||
@ -282,15 +317,17 @@ void UdpServer::sendSbgSolutionModeState(int SolutionMode)
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
|
||||
stateOf300tc.setSbgSolutionMode(SolutionMode);
|
||||
}
|
||||
|
||||
void UdpServer::sendSbgAccuracyState(int Accuracy)
|
||||
void UdpServer::sendSbgAccuracyState(int Accuracy,int SatelliteCounter)
|
||||
{
|
||||
// std::cout<<"UdpServer::sendSbgAccuracyState---------------------:"<< Accuracy <<std::endl;
|
||||
|
||||
QByteArray datagram2send;
|
||||
|
||||
QString status = "Accuracy," + QString::number(Accuracy);
|
||||
QString status = "Accuracy," + QString::number(Accuracy) + "," + QString::number(SatelliteCounter);
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
@ -298,7 +335,7 @@ void UdpServer::sendSbgAccuracyState(int Accuracy)
|
||||
|
||||
void UdpServer::sendXimeaImageStatus(int ximeaImageStatus)
|
||||
{
|
||||
std::cout<<"UdpServer::sendXimeaImageStatus---------------------:"<< ximeaImageStatus <<std::endl;
|
||||
// std::cout<<"UdpServer::sendXimeaImageStatus---------------------:"<< ximeaImageStatus <<std::endl;
|
||||
|
||||
QByteArray datagram2send;
|
||||
|
||||
@ -306,11 +343,54 @@ void UdpServer::sendXimeaImageStatus(int ximeaImageStatus)
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
|
||||
stateOf300tc.setXimeaState(ximeaImageStatus);
|
||||
}
|
||||
|
||||
void UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame(int autoExposeMaxValueOfOneFrame, double exposeTime)
|
||||
{
|
||||
// std::cout<<"UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame---------------------:"<< exposeTime << " " << autoExposeMaxValueOfOneFrame <<std::endl;
|
||||
|
||||
QByteArray datagram2send;
|
||||
|
||||
QString status = "XimeaAutoExpose," + QString::number(autoExposeMaxValueOfOneFrame) + "," + QString::number(exposeTime, 'f', 2);
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
|
||||
stateOf300tc.setExposeTime(exposeTime);
|
||||
stateOf300tc.setExposeMaxValueOfOneFrame(autoExposeMaxValueOfOneFrame);
|
||||
}
|
||||
|
||||
void UdpServer::sendXimeaBinState(int spatialBin, int spectralBin)
|
||||
{
|
||||
// std::cout<<"UdpServer::sendXimeaAutoExposeMaxValueOfOneFrame---------------------:"<< ximeaImageStatus <<std::endl;
|
||||
|
||||
QByteArray datagram2send;
|
||||
|
||||
QString status = "bin," + QString::number(spatialBin) + "," + QString::number(spectralBin);
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
}
|
||||
|
||||
void UdpServer::sendXimeaImageFrameRate(double frameRate)
|
||||
{
|
||||
// std::cout<<"UdpServer::sendXimeaImageFrameRate---------------------:"<< ximeaImageStatus <<std::endl;
|
||||
|
||||
QByteArray datagram2send;
|
||||
|
||||
QString status = "XimeaFrameRate," + QString::number(frameRate, 'f', 2);
|
||||
|
||||
datagram2send.operator =(status.toStdString().c_str());
|
||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||
|
||||
stateOf300tc.setFrameRate(frameRate);
|
||||
}
|
||||
|
||||
void UdpServer::sendCopyFileStatus(int fileStatus)
|
||||
{
|
||||
std::cout<<"UdpServer::sendCopyFileStatus---------------------:"<< fileStatus <<std::endl;
|
||||
// std::cout<<"UdpServer::sendCopyFileStatus---------------------:"<< fileStatus <<std::endl;
|
||||
|
||||
QByteArray datagram2send;
|
||||
|
||||
@ -324,3 +404,199 @@ void UdpServer::onRecordFinished()
|
||||
{
|
||||
std::cout<<"UdpServer::onRecordFinished----------------:影像停止采集"<<std::endl;
|
||||
}
|
||||
|
||||
Record300TcTemperature::Record300TcTemperature()
|
||||
{
|
||||
m_bIsRecord = true;
|
||||
}
|
||||
|
||||
void Record300TcTemperature::stopRecordTemperature()
|
||||
{
|
||||
m_bIsRecord = false;
|
||||
}
|
||||
|
||||
void Record300TcTemperature::recordTemperature(QString filePath= nullptr)
|
||||
{
|
||||
if(filePath== nullptr)
|
||||
filePath="300tcTemperature.csv";
|
||||
QList<QString> fileInfo = getFileInfo(filePath);
|
||||
bool ret = createDir(fileInfo[0]);
|
||||
|
||||
ofstream temperatureFile300Tc(filePath.toStdString().c_str(),ios::app);
|
||||
int counter = 0;
|
||||
|
||||
m_serial=new QSerialPort();
|
||||
|
||||
if(m_serial->isOpen())//如果串口已经打开了 先给他关闭了
|
||||
{
|
||||
m_serial->clear();
|
||||
m_serial->close();
|
||||
}
|
||||
|
||||
QString portname = "ttyUSB2";
|
||||
|
||||
m_serial->setPortName(portname);
|
||||
m_serial->open(QIODevice::ReadWrite);
|
||||
|
||||
bool x=m_serial->setBaudRate(9600);
|
||||
|
||||
QByteArray requestData;
|
||||
while (m_bIsRecord)
|
||||
{
|
||||
counter++;
|
||||
if(m_serial->waitForReadyRead(30000))
|
||||
{
|
||||
requestData = m_serial->readAll();
|
||||
|
||||
float temp = parseMessage(&requestData);
|
||||
if (temp == -10000)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy/MM/dd hh:mm:ss");
|
||||
|
||||
temperatureFile300Tc << currentTime.toStdString() << "," << temp << "\n";
|
||||
|
||||
// if(temp > 80)
|
||||
// {
|
||||
// system("/home/300tc/projects/udpClient/udpClient 127.0.0.1 9,0");
|
||||
// }
|
||||
// if(temp > 90)
|
||||
// {
|
||||
// system("/home/300tc/projects/udpClient/udpClient 127.0.0.1 2");
|
||||
// }
|
||||
//
|
||||
if (counter % 60 == 0)
|
||||
{
|
||||
temperatureFile300Tc.flush();
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// std::cout<<"Record300TcTemperature::recordTemperature--Wait response timeout."<<std::endl;
|
||||
}
|
||||
}
|
||||
m_bIsRecord = true;
|
||||
|
||||
temperatureFile300Tc.close();
|
||||
}
|
||||
|
||||
float Record300TcTemperature::parseMessage(QByteArray * data)
|
||||
{
|
||||
float Lux;
|
||||
float T;
|
||||
float P;
|
||||
float Hum;
|
||||
float H;
|
||||
bool hasTemperature = false;
|
||||
|
||||
// qDebug() << "Received data(hex): " << data->toHex();
|
||||
|
||||
// for (int i = 0; i < data->length(); ++i)
|
||||
// {
|
||||
// qDebug() << i << ":" << (int)data->at(i);
|
||||
// }
|
||||
|
||||
QByteArray target = QByteArray::fromHex("5a5a"); // The pattern to search for
|
||||
|
||||
int offset_tmp = data->indexOf(target);
|
||||
QList<int> offsets;
|
||||
|
||||
while (offset_tmp != -1)
|
||||
{
|
||||
offsets.append(offset_tmp);
|
||||
offset_tmp = data->indexOf(target, offset_tmp + target.size());
|
||||
}
|
||||
|
||||
if (offsets.isEmpty())
|
||||
{
|
||||
// qDebug() << "5A5A not found in the data.";
|
||||
return -10000;
|
||||
}
|
||||
// qDebug() << "5A5A found at offsets:" << offsets;
|
||||
|
||||
for (int i = 0; i < offsets.length(); ++i)
|
||||
{
|
||||
int offset = offsets.at(i);
|
||||
|
||||
int messageClass = data->at(offset + 2);
|
||||
int messageCount = data->at(offset + 3) + 5;
|
||||
// qDebug() << "messageCount:" << messageCount;
|
||||
if (offset + messageCount - 1 > data->length() - 1)
|
||||
{
|
||||
qDebug() << i << ": Some data of this frame is missing! Discarding the frame.";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int checksum = 0;
|
||||
QList<int> numbers;
|
||||
for (int j = 0; j < messageCount - 1; ++j)
|
||||
{
|
||||
if (i==offsets.length()-1 && j== messageCount-1)
|
||||
{
|
||||
int sdf=1;
|
||||
}
|
||||
|
||||
int index = offset + j;
|
||||
|
||||
if (index >= data->length())//Some data of this frame is missing! Discarding the frame.
|
||||
{
|
||||
checksum = -1;
|
||||
break;
|
||||
}
|
||||
int tmp = static_cast<int>(data->at(index));
|
||||
numbers.append(tmp);
|
||||
checksum += tmp;
|
||||
}
|
||||
// qDebug() << "jiaqilai:" << numbers;
|
||||
|
||||
if (checksum == -1)
|
||||
{
|
||||
qDebug() << "Some data of this frame is missing! Discarding the frame.";
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((checksum & 0xFF) != data->at(offset + messageCount - 1))
|
||||
{
|
||||
qDebug() << "Checksum mismatch! Discarding the frame.";
|
||||
continue;
|
||||
}
|
||||
|
||||
//parse data
|
||||
switch (messageClass)
|
||||
{
|
||||
case 0x15:
|
||||
Lux = (float)((data->at(offset + 4)<<24)|(data->at(offset + 5)<<16)|(data->at(offset + 6)<<8)|data->at(offset + 7)) / 100;
|
||||
// qDebug() << "lux: " << Lux;
|
||||
break;
|
||||
case 0x45:
|
||||
T = (float)((data->at(offset + 4)<<8)|data->at(offset + 5)) / 100;
|
||||
P = (float)((data->at(offset + 6)<<24)|(data->at(offset + 7)<<16)|(data->at(offset + 8)<<8)|data->at(offset + 9)) / 100;
|
||||
Hum = (float)((data->at(offset + 10)<<8) | data->at(offset + 11)) / 100;
|
||||
H = (float)((data->at(offset + 12)<<8)|data->at(offset + 13));
|
||||
|
||||
hasTemperature = true;
|
||||
|
||||
// qDebug() << "T: " << T;
|
||||
// qDebug() << "P: " << P;
|
||||
// qDebug() << "Hum: " << Hum;
|
||||
// qDebug() << "H: " << H;
|
||||
break;
|
||||
default : // 可选的
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
if (hasTemperature)
|
||||
{
|
||||
return T;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -10000;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,25 @@
|
||||
#include "Header_Files/utility_tc.h"
|
||||
#include <QDir>
|
||||
|
||||
QString formatTimeStr(char * format)
|
||||
{
|
||||
//获取系统时间
|
||||
time_t timer;//time_t就是long int 类型
|
||||
struct tm *tblock;
|
||||
timer = time(NULL);//返回秒数(精度为秒),从1970-1-1,00:00:00 可以当成整型输出或用于其它函数
|
||||
tblock = localtime(&timer);
|
||||
//printf("Local time is: %s\n", asctime(tblock));
|
||||
|
||||
//格式化时间为需要的格式
|
||||
char timeStr_tmp[256] = { 0 };
|
||||
strftime(timeStr_tmp, sizeof(timeStr_tmp), format, tblock);//
|
||||
|
||||
QString timeStr2(timeStr_tmp);
|
||||
// qDebug() << "time is:" << timeStr2;
|
||||
|
||||
return timeStr2;
|
||||
}
|
||||
|
||||
QString getFileNameBaseOnTime()
|
||||
{
|
||||
using namespace std;
|
||||
@ -69,3 +88,36 @@ void swap(unsigned short * a, unsigned short * b)
|
||||
*a=*b;
|
||||
*b=tmp;
|
||||
}
|
||||
|
||||
|
||||
bool createDir(QString fullPath)
|
||||
{
|
||||
QDir dir(fullPath);
|
||||
if (dir.exists()) {
|
||||
return true;
|
||||
} else {
|
||||
bool ok = dir.mkpath(fullPath);//创建多级目录
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
QList<QString> getFileInfo(QString file)
|
||||
{
|
||||
QFileInfo fileInfo = QFileInfo(file);
|
||||
|
||||
QString fileName, fileSuffix, filePath;
|
||||
filePath = fileInfo.absolutePath();//绝对路径
|
||||
fileName = fileInfo.fileName();//文件名
|
||||
fileSuffix = fileInfo.suffix();//文件后缀
|
||||
|
||||
// qDebug() << fileName <<endl
|
||||
// << fileSuffix<< endl
|
||||
// << filePath<< endl;
|
||||
|
||||
QList<QString> result;
|
||||
result.append(filePath);
|
||||
result.append(fileName);
|
||||
result.append(fileSuffix);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user