Compare commits
37 Commits
c35568bb2e
...
44
Author | SHA1 | Date | |
---|---|---|---|
faf83b2545 | |||
e8760dcfe5 | |||
bd4d055129 | |||
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 | |||
87a35f5dd4 | |||
374a48022b |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
.idea
|
.idea
|
||||||
build
|
build
|
||||||
|
/温度测试
|
||||||
|
扩展板接口.txt
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.5.2)
|
||||||
project(ximeaAirborneSystem)
|
project(ximeaAirborneSystem)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
@ -9,7 +9,7 @@ set(CMAKE_AUTOUIC ON)
|
|||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
set(QT Core Network SerialPort)
|
set(QT Core Network SerialPort Gui)
|
||||||
set(TEMPLATE app)
|
set(TEMPLATE app)
|
||||||
set(TARGET ximeaImageRecorder)
|
set(TARGET ximeaImageRecorder)
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
@ -17,9 +17,15 @@ find_package(Qt5 REQUIRED ${QT})#
|
|||||||
|
|
||||||
include_directories(.)
|
include_directories(.)
|
||||||
include_directories(/home/300tc/library/ximeaControlDll/Header_Files)
|
include_directories(/home/300tc/library/ximeaControlDll/Header_Files)
|
||||||
|
|
||||||
link_directories(/home/300tc/library/ximeaControlDll)
|
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}
|
add_executable(${CMAKE_PROJECT_NAME}
|
||||||
Source_Files/fileoperation.cpp
|
Source_Files/fileoperation.cpp
|
||||||
Header_Files/fileoperation.h
|
Header_Files/fileoperation.h
|
||||||
@ -41,10 +47,17 @@ add_executable(${CMAKE_PROJECT_NAME}
|
|||||||
Source_Files/ximeaimager.cpp
|
Source_Files/ximeaimager.cpp
|
||||||
Header_Files/ximeaimager.h
|
Header_Files/ximeaimager.h
|
||||||
Source_Files/configfile.cpp
|
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})
|
qt5_use_modules(${CMAKE_PROJECT_NAME} ${QT})
|
||||||
|
|
||||||
target_link_libraries(${CMAKE_PROJECT_NAME}
|
target_link_libraries(${CMAKE_PROJECT_NAME}
|
||||||
irisXimeaImager
|
irisXimeaImager
|
||||||
libconfig.so
|
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,9 +9,14 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <libconfig.h++>
|
#include <libconfig.h++>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#include "utility_tc.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace libconfig;
|
using namespace libconfig;
|
||||||
@ -25,10 +30,19 @@ public:
|
|||||||
bool isConfigfileExist();
|
bool isConfigfileExist();
|
||||||
bool parseConfigfile();
|
bool parseConfigfile();
|
||||||
|
|
||||||
bool getBin(int &bin);
|
bool getSpectralBin(int &spectralBin);
|
||||||
|
bool getspatialBin(int &spatialBin);
|
||||||
bool getEffectiveWindow(int &width, int &offsetx, int &height, int &offsety);
|
bool getEffectiveWindow(int &width, int &offsetx, int &height, int &offsety);
|
||||||
bool getEffectiveWindowRoi(int &width, int &offsetx);
|
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 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 createConfigFile();
|
||||||
bool updateConfigFile();
|
bool updateConfigFile();
|
||||||
@ -37,4 +51,55 @@ private:
|
|||||||
string m_configfilePath;
|
string m_configfilePath;
|
||||||
Config cfg;
|
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
|
#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 sbgSolutionModeSignal(int);
|
||||||
|
|
||||||
void sbgAccuracySignal(int);
|
void sbgAccuracySignal(int, int);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,17 +11,43 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QtSerialPort/QSerialPort>
|
||||||
|
#include <QtSerialPort/QSerialPortInfo>
|
||||||
|
|
||||||
#include "ximeaimager.h"
|
#include "ximeaimager.h"
|
||||||
#include "sbgrecorder.h"
|
#include "sbgrecorder.h"
|
||||||
#include "fileoperation.h"
|
#include "fileoperation.h"
|
||||||
|
|
||||||
|
#include "configfile.h"
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
// #include <sbgEComLib.h>
|
// #include <sbgEComLib.h>
|
||||||
#include <stdlib.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
|
class UdpServer:public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -48,6 +74,11 @@ class UdpServer:public QObject
|
|||||||
|
|
||||||
void sender(int status);
|
void sender(int status);
|
||||||
|
|
||||||
|
QThread * m_recordTempThread;
|
||||||
|
Record300TcTemperature * m_300tcTemperature;
|
||||||
|
|
||||||
|
StateOf300tcConfigfile stateOf300tc;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void systemStart();
|
void systemStart();
|
||||||
void systemStop();
|
void systemStop();
|
||||||
@ -56,6 +87,7 @@ signals:
|
|||||||
void startDeleteFileSignal();
|
void startDeleteFileSignal();
|
||||||
|
|
||||||
void recordXimeaOnlySignal(double,QString);
|
void recordXimeaOnlySignal(double,QString);
|
||||||
|
void record300tcTemperatureSignal(QString);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onRecordFinished();
|
void onRecordFinished();
|
||||||
@ -63,9 +95,12 @@ public slots:
|
|||||||
void sendSerialPortStatus(int serialPortStatus);
|
void sendSerialPortStatus(int serialPortStatus);
|
||||||
|
|
||||||
void sendSbgSolutionModeState(int SolutionMode);
|
void sendSbgSolutionModeState(int SolutionMode);
|
||||||
void sendSbgAccuracyState(int Accuracy);
|
void sendSbgAccuracyState(int Accuracy,int SatelliteCounter);
|
||||||
|
|
||||||
void sendXimeaImageStatus(int ximeaImageStatus);
|
void sendXimeaImageStatus(int ximeaImageStatus);
|
||||||
|
void sendXimeaAutoExposeMaxValueOfOneFrame(int autoExposeMaxValueOfOneFrame, double exposeTime);
|
||||||
|
void sendXimeaBinState(int spatialBin, int spectralBin);
|
||||||
|
void sendXimeaImageFrameRate(double frameRate);
|
||||||
void sendCopyFileStatus(int fileStatus);
|
void sendCopyFileStatus(int fileStatus);
|
||||||
};
|
};
|
||||||
#endif // UDPSERVER_H
|
#endif // UDPSERVER_H
|
||||||
|
@ -2,15 +2,22 @@
|
|||||||
#define UTILITY_TC_H
|
#define UTILITY_TC_H
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
QString getFileNameBaseOnTime();
|
QString getFileNameBaseOnTime();
|
||||||
|
|
||||||
|
QString formatTimeStr(char * format);
|
||||||
|
|
||||||
//https://blog.csdn.net/MoreWindows/article/details/6657829
|
//https://blog.csdn.net/MoreWindows/article/details/6657829
|
||||||
void bubbleSort(unsigned short * a, int n);
|
void bubbleSort(unsigned short * a, int n);
|
||||||
|
|
||||||
void swap(unsigned short * a, unsigned short * b);
|
void swap(unsigned short * a, unsigned short * b);
|
||||||
|
|
||||||
|
bool createDir(QString fullPath);
|
||||||
|
|
||||||
|
QList<QString> getFileInfo(QString file);
|
||||||
|
|
||||||
#endif // UTILITY_TC_H
|
#endif // UTILITY_TC_H
|
||||||
|
@ -25,10 +25,15 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <cmath>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <qthread.h>
|
#include <qthread.h>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
#include "configfile.h"
|
#include "configfile.h"
|
||||||
|
|
||||||
@ -36,6 +41,16 @@
|
|||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "utility_tc.h"
|
#include "utility_tc.h"
|
||||||
|
|
||||||
|
#include "MemoryPool.h"
|
||||||
|
#include <queue>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QUdpSocket>
|
||||||
|
|
||||||
|
#include "rgbImage.h"
|
||||||
|
|
||||||
|
#define PUSH_FLOW_PORT 666
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#ifdef WIN32
|
//#ifdef WIN32
|
||||||
//#include <xiApi.h> // Windows
|
//#include <xiApi.h> // Windows
|
||||||
@ -43,12 +58,30 @@
|
|||||||
//#include <m3api/xiApi.h> // Linux, OSX
|
//#include <m3api/xiApi.h> // Linux, OSX
|
||||||
//#endif
|
//#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
|
class RecordXimeaTemperature : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RecordXimeaTemperature(Iris::IrisXimeaImager * imager);
|
RecordXimeaTemperature(Iris::IrisXimeaImager * imager, XimeaImager * ximeaImager);
|
||||||
|
|
||||||
void stopRecordTemperature();
|
void stopRecordTemperature();
|
||||||
|
|
||||||
@ -56,6 +89,7 @@ private:
|
|||||||
Iris::IrisXimeaImager * m_imager;
|
Iris::IrisXimeaImager * m_imager;
|
||||||
|
|
||||||
bool m_bIsRecord;
|
bool m_bIsRecord;
|
||||||
|
XimeaImager * m_ximeaImager;
|
||||||
public slots:
|
public slots:
|
||||||
void recordTemperature(QString filePath);
|
void recordTemperature(QString filePath);
|
||||||
|
|
||||||
@ -63,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
|
class XimeaImager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
XimeaImager();
|
XimeaImager();
|
||||||
|
~XimeaImager();
|
||||||
|
|
||||||
void setFramerate(double framerate);
|
void setFramerate(double framerate);
|
||||||
double getFramerate();
|
double getFramerate();
|
||||||
double setExposureTime(float exposureTime);
|
double setExposureTime(float exposureTime_in_us);
|
||||||
|
int wrapSetExposureTime(float exposureTime_in_us);
|
||||||
double getExposureTime();
|
double getExposureTime();
|
||||||
double autoExposure();
|
double autoExposure();
|
||||||
void setGain(double gain);
|
void setGain(double gain);
|
||||||
@ -84,8 +176,12 @@ public:
|
|||||||
int getWindowEndBand();
|
int getWindowEndBand();
|
||||||
double geWavelengthAtBand(int x);
|
double geWavelengthAtBand(int x);
|
||||||
|
|
||||||
|
static int findClosestIndex(const std::vector<double>& numbers, double target);
|
||||||
|
void getRgbBandNumber(int &redBandNumber, int &greenBandNumber, int &blueBandNumber);
|
||||||
|
|
||||||
void stopRecord();
|
void stopRecord();
|
||||||
int getFrameCounter();
|
int getFrameCounter();
|
||||||
|
void writeXiApiErrorCodes(QString filePath, int xiApiErrorCodes);
|
||||||
|
|
||||||
int getMaxValueOfOneFrame(unsigned short * data, int numberOfPixel);
|
int getMaxValueOfOneFrame(unsigned short * data, int numberOfPixel);
|
||||||
|
|
||||||
@ -95,46 +191,52 @@ private:
|
|||||||
int m_iImagerState;
|
int m_iImagerState;
|
||||||
int m_iImagerStateTemp;
|
int m_iImagerStateTemp;
|
||||||
|
|
||||||
|
int m_iOffsetyOfSpectralBin1, m_iOffsetyOfSpectralBin2;
|
||||||
|
int m_iHeightOfSpectralBin1, m_iHeightOfSpectralBin2;
|
||||||
|
|
||||||
QThread * m_recordTempThread;
|
QThread * m_recordTempThread;
|
||||||
RecordXimeaTemperature * m_ximeaTemperature;
|
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_baseFileName;
|
||||||
QString m_ximeaTemperatureCSVPath;
|
QString m_ximeaTemperatureCSVPath;
|
||||||
|
|
||||||
Iris::IrisXimeaImager m_imager;
|
Iris::IrisXimeaImager m_imager;
|
||||||
unsigned short * m_buffer;
|
unsigned short * m_buffer;
|
||||||
|
// MemoryPool<unsigned short> m_pool;
|
||||||
bool m_bRecordControl;
|
bool m_bRecordControl;
|
||||||
int m_iFrameCounter;
|
int m_iFrameCounter;
|
||||||
int m_iFrameSizeInByte;
|
int m_iFrameSizeInByte;
|
||||||
|
rgbImage * m_rgbImage;
|
||||||
void writeHdr();
|
void writeHdr();
|
||||||
|
|
||||||
void processXiApiErrorCodes(int xiApiErrorCodes);
|
void processXiApiErrorCodes(int xiApiErrorCodes);
|
||||||
|
|
||||||
inline double getSbgTime(double TimeDifferenceBetweensOSAndSbg)
|
inline double getSbgTime(XI_IMG * image, double timeDifferenceBetweenSbgAndXimea)
|
||||||
{
|
{
|
||||||
struct timespec systemTime;
|
double ximeaTime = (double)image->tsSec + (double)image->tsUSec/1000000;
|
||||||
clock_gettime(CLOCK_REALTIME,&systemTime);
|
return ximeaTime + timeDifferenceBetweenSbgAndXimea;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Configfile m_configfile;
|
Configfile m_configfile;
|
||||||
|
ParameterConfigfile m_parameterConfigfile;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void openImger();
|
void openImger();
|
||||||
void closeImger();
|
void closeImger();
|
||||||
|
|
||||||
|
double calculateTimeDifferenceBetweenSbgAndximea(XI_IMG * m_image, double timeDifferenceBetweenSbgAndOS);
|
||||||
void startRecord(double TimeDifferenceBetweensOSAndSbg,QString baseFileName);
|
void startRecord(double TimeDifferenceBetweensOSAndSbg,QString baseFileName);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -142,5 +244,11 @@ signals:
|
|||||||
void ximeaImageStatus(int);
|
void ximeaImageStatus(int);
|
||||||
|
|
||||||
void recordXimeaTemperatureSignal(QString);
|
void recordXimeaTemperatureSignal(QString);
|
||||||
|
void startWriteDiskSignal();
|
||||||
|
void startPushFlowSignal();
|
||||||
|
|
||||||
|
void autoExposeMaxValueOfOneFrame(int, double);
|
||||||
|
void frameRateSignal(double);
|
||||||
|
void binSignal(int, int);
|
||||||
};
|
};
|
||||||
#endif // XIMEAIMAGER_H
|
#endif // XIMEAIMAGER_H
|
||||||
|
@ -43,17 +43,32 @@ bool Configfile::parseConfigfile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configfile::getBin(int &bin)
|
bool Configfile::getSpectralBin(int &spectralBin)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bin = cfg.lookup("bin");
|
spectralBin = cfg.lookup("spectralBin");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(const SettingNotFoundException &nfex)
|
catch(const SettingNotFoundException &nfex)
|
||||||
{
|
{
|
||||||
cerr << "No 'bin' setting in configuration file." << endl;
|
cerr << "No 'spectralBin' setting in configuration file." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Configfile::getspatialBin(int &spatialBin)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
spatialBin = cfg.lookup("spatialBin");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch(const SettingNotFoundException &nfex)
|
||||||
|
{
|
||||||
|
cerr << "No 'spatialBin' setting in configuration file." << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,22 +77,41 @@ bool Configfile::getEffectiveWindow(int &width, int &offsetx, int &height, int &
|
|||||||
{
|
{
|
||||||
const Setting& root = cfg.getRoot();
|
const Setting& root = cfg.getRoot();
|
||||||
|
|
||||||
// Output a list of all books in the inventory.
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const Setting &effective_window = root["effective_window"];
|
int spatialBin;
|
||||||
int count = effective_window.getLength();
|
int spectralBin;
|
||||||
|
getspatialBin(spatialBin);
|
||||||
|
getSpectralBin(spectralBin);
|
||||||
|
|
||||||
int bin;
|
string spatialBinString;
|
||||||
getBin(bin);
|
if(spatialBin == 1)
|
||||||
|
{
|
||||||
|
spatialBinString = "bin1";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
spatialBinString = "bin2";
|
||||||
|
}
|
||||||
|
const Setting &spatialArgument = root["effective_window"][spatialBinString]["spatial"];
|
||||||
|
if(!(spatialArgument.lookupValue("width", width)
|
||||||
|
&& spatialArgument.lookupValue("offsetx", offsetx)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const Setting &window = effective_window[bin-1];
|
string spectralBinString;
|
||||||
string name = window.getName();
|
if(spectralBin == 1)
|
||||||
|
{
|
||||||
if(!(window.lookupValue("width", width)
|
spectralBinString = "bin1";
|
||||||
&& window.lookupValue("offsetx", offsetx)
|
}
|
||||||
&& window.lookupValue("height", height)
|
else
|
||||||
&& window.lookupValue("offsety", offsety)))
|
{
|
||||||
|
spectralBinString = "bin2";
|
||||||
|
}
|
||||||
|
const Setting &spectralArgument = root["effective_window"][spectralBinString]["spectral"];
|
||||||
|
if(!(spectralArgument.lookupValue("height", height)
|
||||||
|
&& spectralArgument.lookupValue("offsety", offsety)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -95,16 +129,25 @@ bool Configfile::getEffectiveWindowRoi(int &width, int &offsetx)
|
|||||||
{
|
{
|
||||||
const Setting& root = cfg.getRoot();
|
const Setting& root = cfg.getRoot();
|
||||||
|
|
||||||
// Output a list of all books in the inventory.
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const Setting &effective_window = root["effective_window_roi"];
|
const Setting &effective_window = root["effective_window_roi"];
|
||||||
int count = effective_window.getLength();
|
int count = effective_window.getLength();
|
||||||
|
|
||||||
int bin;
|
int spatialBin;
|
||||||
getBin(bin);
|
getspatialBin(spatialBin);
|
||||||
|
|
||||||
const Setting &window = effective_window[bin-1];
|
string spatialBinString;
|
||||||
|
if(spatialBin == 1)
|
||||||
|
{
|
||||||
|
spatialBinString = "spatialBin1";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
spatialBinString = "spatialBin2";
|
||||||
|
}
|
||||||
|
|
||||||
|
const Setting &window = effective_window[spatialBinString];
|
||||||
string name = window.getName();
|
string name = window.getName();
|
||||||
|
|
||||||
if(!(window.lookupValue("width", width)
|
if(!(window.lookupValue("width", width)
|
||||||
@ -123,20 +166,109 @@ bool Configfile::getEffectiveWindowRoi(int &width, int &offsetx)
|
|||||||
return true;
|
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)
|
bool Configfile::getGainOffset(float &gain, float &offset)
|
||||||
{
|
{
|
||||||
const Setting& root = cfg.getRoot();
|
const Setting& root = cfg.getRoot();
|
||||||
|
|
||||||
// Output a list of all books in the inventory.
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const Setting &gainOffset = root["gainOffset"];
|
const Setting &gainOffset = root["gainOffset"];
|
||||||
int count = gainOffset.getLength();
|
int count = gainOffset.getLength();
|
||||||
|
|
||||||
int bin;
|
int spectralBin;
|
||||||
getBin(bin);
|
getSpectralBin(spectralBin);
|
||||||
|
|
||||||
const Setting &gainOffsetSetting = gainOffset[bin-1];
|
string spectralBinString;
|
||||||
|
if(spectralBin == 1)
|
||||||
|
{
|
||||||
|
spectralBinString = "spectralBin1";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
spectralBinString = "spectralBin2";
|
||||||
|
}
|
||||||
|
|
||||||
|
const Setting &gainOffsetSetting = gainOffset[spectralBinString];
|
||||||
string name = gainOffsetSetting.getName();
|
string name = gainOffsetSetting.getName();
|
||||||
|
|
||||||
if(!(gainOffsetSetting.lookupValue("gain", gain)
|
if(!(gainOffsetSetting.lookupValue("gain", gain)
|
||||||
@ -154,69 +286,175 @@ bool Configfile::getGainOffset(float &gain, float &offset)
|
|||||||
return true;
|
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()
|
bool Configfile::createConfigFile()
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace libconfig;
|
using namespace libconfig;
|
||||||
|
|
||||||
static const char *output_file = "ximea.cfg";
|
|
||||||
Config cfg;
|
Config cfg;
|
||||||
|
|
||||||
Setting &root = cfg.getRoot();
|
Setting &root = cfg.getRoot();
|
||||||
|
|
||||||
// Add some settings to the configuration.
|
// Add some settings to the configuration.
|
||||||
Setting &bin = root.add("bin", Setting::TypeInt) = 1;
|
|
||||||
Setting &SN = root.add("SN", Setting::TypeString) = "0098";
|
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 &effective_window = root.add("effective_window", Setting::TypeGroup);
|
Setting &effective_window = root.add("effective_window", Setting::TypeGroup);
|
||||||
Setting &effective_window_Bin1 = effective_window.add("bin1", Setting::TypeGroup);
|
Setting &effective_window_Bin1 = effective_window.add("bin1", Setting::TypeGroup);
|
||||||
|
Setting &effective_window_Bin1_spatial = effective_window_Bin1.add("spatial", Setting::TypeGroup);
|
||||||
|
Setting &effective_window_Bin1_Spectral = effective_window_Bin1.add("spectral", Setting::TypeGroup);
|
||||||
Setting &effective_window_Bin2 = effective_window.add("bin2", Setting::TypeGroup);
|
Setting &effective_window_Bin2 = effective_window.add("bin2", Setting::TypeGroup);
|
||||||
|
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.add("width", Setting::TypeInt) = 1392;
|
effective_window_Bin1_spatial.add("width", Setting::TypeInt) = 1368;
|
||||||
effective_window_Bin1.add("offsetx", Setting::TypeInt) = 272;
|
effective_window_Bin1_spatial.add("offsetx", Setting::TypeInt) = 288;
|
||||||
effective_window_Bin1.add("height", Setting::TypeInt) = 300;
|
effective_window_Bin1_Spectral.add("height", Setting::TypeInt) = 300;
|
||||||
effective_window_Bin1.add("offsety", Setting::TypeInt) = 348;
|
effective_window_Bin1_Spectral.add("offsety", Setting::TypeInt) = 348;
|
||||||
|
|
||||||
effective_window_Bin2.add("width", Setting::TypeInt) = 712;
|
effective_window_Bin2_spatial.add("width", Setting::TypeInt) = 688;
|
||||||
effective_window_Bin2.add("offsetx", Setting::TypeInt) = 128;
|
effective_window_Bin2_spatial.add("offsetx", Setting::TypeInt) = 144;
|
||||||
effective_window_Bin2.add("height", Setting::TypeInt) = 151;
|
effective_window_Bin2_Spectral.add("height", Setting::TypeInt) = 150;
|
||||||
effective_window_Bin2.add("offsety", Setting::TypeInt) = 174;
|
effective_window_Bin2_Spectral.add("offsety", Setting::TypeInt) = 174;
|
||||||
|
|
||||||
Setting &effective_window_roi = root.add("effective_window_roi", Setting::TypeGroup);
|
Setting &effective_window_roi = root.add("effective_window_roi", Setting::TypeGroup);
|
||||||
Setting &effective_window_roi_Bin1 = effective_window_roi.add("bin1", Setting::TypeGroup);
|
Setting &effective_window_roi_spatialBin1 = effective_window_roi.add("spatialBin1", Setting::TypeGroup);
|
||||||
Setting &effective_window_roi_Bin2 = effective_window_roi.add("bin2", Setting::TypeGroup);
|
Setting &effective_window_roi_spatialBin2 = effective_window_roi.add("spatialBin2", Setting::TypeGroup);
|
||||||
|
|
||||||
effective_window_roi_Bin1.add("width", Setting::TypeInt) = 1364;
|
effective_window_roi_spatialBin1.add("width", Setting::TypeInt) = 1364;
|
||||||
effective_window_roi_Bin1.add("offsetx", Setting::TypeInt) = 14;
|
effective_window_roi_spatialBin1.add("offsetx", Setting::TypeInt) = 14;
|
||||||
// effective_window_roi_Bin1.add("height", Setting::TypeInt) = 300;
|
// effective_window_roi_Bin1.add("height", Setting::TypeInt) = 300;
|
||||||
// effective_window_roi_Bin1.add("offsety", Setting::TypeInt) = 348;
|
// effective_window_roi_Bin1.add("offsety", Setting::TypeInt) = 348;
|
||||||
|
|
||||||
effective_window_roi_Bin2.add("width", Setting::TypeInt) = 682;
|
effective_window_roi_spatialBin2.add("width", Setting::TypeInt) = 682;
|
||||||
effective_window_roi_Bin2.add("offsetx", Setting::TypeInt) = 15;
|
effective_window_roi_spatialBin2.add("offsetx", Setting::TypeInt) = 15;
|
||||||
// effective_window_roi_Bin2.add("height", Setting::TypeInt) = 151;
|
// effective_window_roi_Bin2.add("height", Setting::TypeInt) = 151;
|
||||||
// effective_window_roi_Bin2.add("offsety", Setting::TypeInt) = 174;
|
// effective_window_roi_Bin2.add("offsety", Setting::TypeInt) = 174;
|
||||||
|
|
||||||
Setting &gainOffset = root.add("gainOffset", Setting::TypeGroup);
|
Setting &gainOffset = root.add("gainOffset", Setting::TypeGroup);
|
||||||
Setting &gainOffsetBin1 = gainOffset.add("bin1", Setting::TypeGroup);
|
Setting &gainOffsetSpectralBin1 = gainOffset.add("spectralBin1", Setting::TypeGroup);
|
||||||
Setting &gainOffsetBin2 = gainOffset.add("bin2", Setting::TypeGroup);
|
Setting &gainOffsetSpectralBin2 = gainOffset.add("spectralBin2", Setting::TypeGroup);
|
||||||
|
|
||||||
gainOffsetBin1.add("gain", Setting::TypeFloat) = 2.00313433;
|
gainOffsetSpectralBin1.add("gain", Setting::TypeFloat) = 2.00313433;
|
||||||
gainOffsetBin1.add("offset", Setting::TypeFloat) = -300.46283157590585;
|
gainOffsetSpectralBin1.add("offset", Setting::TypeFloat) = -300.46283157590585;
|
||||||
|
|
||||||
gainOffsetBin2.add("gain", Setting::TypeFloat) = 4.00626868;
|
gainOffsetSpectralBin2.add("gain", Setting::TypeFloat) = 4.00626868;
|
||||||
gainOffsetBin2.add("offset", Setting::TypeFloat) = -299.46126663407176;
|
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;
|
||||||
|
|
||||||
|
Setting &push_flow_param = root.add("push_flow_param", Setting::TypeGroup);
|
||||||
|
push_flow_param.add("flow_switch", Setting::TypeInt) = 1;
|
||||||
|
push_flow_param.add("rgb_height", Setting::TypeInt) = 720;
|
||||||
|
push_flow_param.add("framerate_video", Setting::TypeInt) = 5;
|
||||||
|
|
||||||
// Write out the new configuration.
|
// Write out the new configuration.
|
||||||
|
QString output_file = "/media/nvme/300TC/config/ximea.cfg";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
cfg.writeFile(output_file);
|
QList<QString> fileInfo = getFileInfo(output_file);
|
||||||
cerr << "New configuration successfully written to: " << output_file << endl;
|
bool ret = createDir(fileInfo[0]);
|
||||||
|
|
||||||
|
cfg.writeFile(output_file.toStdString().c_str());
|
||||||
|
cerr << "New configuration successfully written to: " << output_file.toStdString().c_str() << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(const FileIOException &fioex)
|
catch(const FileIOException &fioex)
|
||||||
{
|
{
|
||||||
cerr << "I/O error while writing configuration file: " << output_file << endl;
|
cerr << "I/O error while writing configuration file: " << output_file.toStdString().c_str() << endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,3 +530,295 @@ bool Configfile::updateConfigFile()
|
|||||||
|
|
||||||
return true;
|
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[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
std::cout<<"ximeaAirborneSystem 版本:"<< "44." <<std::endl;
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
//UdpServer* x=new UdpServer();
|
//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 = "sbg_serial_port";
|
||||||
QString portname = "ttyS4";
|
QString portname = "ttyUSB0";
|
||||||
|
|
||||||
m_serial->setPortName(portname);
|
m_serial->setPortName(portname);
|
||||||
m_serial->open(QIODevice::ReadWrite);
|
m_serial->open(QIODevice::ReadWrite);
|
||||||
@ -608,76 +608,51 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
|||||||
//判断模式是否为: NAV_POSITION
|
//判断模式是否为: NAV_POSITION
|
||||||
if(receivedMsgClass==SBG_ECOM_CLASS_LOG_ECOM_0 && receivedMsg==SBG_ECOM_LOG_EKF_EULER)
|
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 status=logData.ekfEulerData.status;
|
||||||
uint32_t mode=status>>24;//?????????????????????????????????????
|
uint32_t mode=status & 0xf;
|
||||||
// uint32_t mode=status;//这是错的
|
|
||||||
|
|
||||||
//一秒钟发射一次mode
|
//一秒钟发射一次mode
|
||||||
if(m_iSolutionModeCounter%200 == 0)
|
if(m_iSolutionModeCounter%200 == 0)
|
||||||
{
|
{
|
||||||
emit sbgSolutionModeSignal(mode);
|
emit sbgSolutionModeSignal(mode);
|
||||||
|
// std::cout << "logData.ekfEulerData.status: " << status << std::endl;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode) {
|
||||||
{
|
|
||||||
case SBG_ECOM_SOL_MODE_UNINITIALIZED:
|
case SBG_ECOM_SOL_MODE_UNINITIALIZED:
|
||||||
std::cout<<"此刻模式为: "<<"UNINITIALIZED"<<std::endl;
|
// std::cout << "此刻模式为: " << "UNINITIALIZED" << std::endl;
|
||||||
|
m_bIsNAV_POSITION_MODE = false;
|
||||||
break;
|
break;
|
||||||
case SBG_ECOM_SOL_MODE_VERTICAL_GYRO:
|
case SBG_ECOM_SOL_MODE_VERTICAL_GYRO:
|
||||||
std::cout<<"此刻模式为: "<<"VERTICAL_GYRO"<<std::endl;
|
// std::cout << "此刻模式为: " << "VERTICAL_GYRO" << std::endl;
|
||||||
|
m_bIsNAV_POSITION_MODE = false;
|
||||||
break;
|
break;
|
||||||
case SBG_ECOM_SOL_MODE_AHRS:
|
case SBG_ECOM_SOL_MODE_AHRS:
|
||||||
std::cout<<"此刻模式为: "<<"AHRS"<<std::endl;
|
// std::cout << "此刻模式为: " << "AHRS" << std::endl;
|
||||||
|
m_bIsNAV_POSITION_MODE = false;
|
||||||
break;
|
break;
|
||||||
case SBG_ECOM_SOL_MODE_NAV_VELOCITY:
|
case SBG_ECOM_SOL_MODE_NAV_VELOCITY:
|
||||||
std::cout<<"此刻模式为: "<<"NAV_VELOCITY"<<std::endl;
|
// std::cout << "此刻模式为: " << "NAV_VELOCITY" << std::endl;
|
||||||
|
m_bIsNAV_POSITION_MODE = false;
|
||||||
break;
|
break;
|
||||||
case SBG_ECOM_SOL_MODE_NAV_POSITION:
|
case SBG_ECOM_SOL_MODE_NAV_POSITION:
|
||||||
std::cout<<"此刻模式为: "<<"NAV_POSITION"<<std::endl;
|
// std::cout << "此刻模式为: " << "NAV_POSITION" << std::endl;
|
||||||
|
m_bIsNAV_POSITION_MODE = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
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)
|
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 maximal=0;
|
||||||
float latitudeAccuracy=logData.gpsPosData.latitudeAccuracy;
|
float latitudeAccuracy=logData.gpsPosData.latitudeAccuracy;
|
||||||
float longitudeAccuracy=logData.gpsPosData.longitudeAccuracy;
|
float longitudeAccuracy=logData.gpsPosData.longitudeAccuracy;
|
||||||
float altitudeAccuracy=logData.gpsPosData.altitudeAccuracy;
|
float altitudeAccuracy=logData.gpsPosData.altitudeAccuracy;
|
||||||
|
int satelliteCounter=(int)logData.gpsPosData.numSvUsed;
|
||||||
|
|
||||||
if(latitudeAccuracy<longitudeAccuracy)
|
if(latitudeAccuracy<longitudeAccuracy)
|
||||||
maximal = longitudeAccuracy;
|
maximal = longitudeAccuracy;
|
||||||
@ -687,7 +662,14 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
|||||||
if(maximal<altitudeAccuracy)
|
if(maximal<altitudeAccuracy)
|
||||||
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)
|
if(maximal<7)
|
||||||
{
|
{
|
||||||
@ -710,15 +692,10 @@ void sbgtc::SbgRecorder::parseSbgMessage(QByteArray * sbgMessage)
|
|||||||
char setGpsTimeCommand[256];
|
char setGpsTimeCommand[256];
|
||||||
sprintf(setGpsTimeCommand,"date --set=\"%d%02d%02d %02d:%02d:%02d\"",year,month,day,hour,minute,second);//02中的2代表2位数字,0代表以0补全
|
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;
|
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)
|
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;
|
//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 &&
|
//控制开始采集高光谱影像,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();
|
m_baseFileName=getFileNameBaseOnTime();
|
||||||
emit sbgReady(calculateTimeDifferenceBetweenSystemAndSbg(logData),m_baseFileName);
|
emit sbgReady(calculateTimeDifferenceBetweenSystemAndSbg(logData),m_baseFileName);
|
||||||
@ -793,7 +770,7 @@ void sbgtc::SbgRecorder::startRecordSbg()
|
|||||||
|
|
||||||
m_baseFileName=getFileNameBaseOnTime();
|
m_baseFileName=getFileNameBaseOnTime();
|
||||||
|
|
||||||
QString sbgFileName=m_baseFileName+".sbg";
|
QString sbgFileName=m_baseFileName+".bin";
|
||||||
|
|
||||||
FILE * fileHandle=fopen(sbgFileName.toStdString().c_str(),"w+b");
|
FILE * fileHandle=fopen(sbgFileName.toStdString().c_str(),"w+b");
|
||||||
|
|
||||||
@ -802,7 +779,7 @@ void sbgtc::SbgRecorder::startRecordSbg()
|
|||||||
while (m_bRecordControl)
|
while (m_bRecordControl)
|
||||||
{
|
{
|
||||||
//std::cout<<"SbgRecorder::startRecordSbg--------------:"<<std::endl;
|
//std::cout<<"SbgRecorder::startRecordSbg--------------:"<<std::endl;
|
||||||
if(m_serial->waitForReadyRead())
|
if(m_serial->waitForReadyRead(30000))
|
||||||
{
|
{
|
||||||
//requestData.resize(m_serial->size());
|
//requestData.resize(m_serial->size());
|
||||||
requestData = m_serial->readAll();
|
requestData = m_serial->readAll();
|
||||||
|
@ -8,16 +8,16 @@ UdpServer::UdpServer()
|
|||||||
m_udpSocket->bind(45454, QUdpSocket::ShareAddress);
|
m_udpSocket->bind(45454, QUdpSocket::ShareAddress);
|
||||||
connect(m_udpSocket, SIGNAL(readyRead()),this, SLOT(processPendingDatagrams()));
|
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_RecordSbgThread=new QThread();
|
||||||
m_sbgRecorder=new sbgtc::SbgRecorder();
|
m_sbgRecorder=new sbgtc::SbgRecorder();
|
||||||
m_sbgRecorder->moveToThread(m_RecordSbgThread);
|
m_sbgRecorder->moveToThread(m_RecordSbgThread);
|
||||||
m_RecordSbgThread->start();
|
m_RecordSbgThread->start();
|
||||||
|
|
||||||
m_RecordThread=new QThread();
|
|
||||||
m_imager=new XimeaImager();
|
|
||||||
m_imager->moveToThread(m_RecordThread);
|
|
||||||
m_RecordThread->start();
|
|
||||||
|
|
||||||
m_CopyFileThread=new QThread();
|
m_CopyFileThread=new QThread();
|
||||||
m_copyFile=new FileOperation();
|
m_copyFile=new FileOperation();
|
||||||
m_copyFile->moveToThread(m_CopyFileThread);
|
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(serialPortStatus(int)),this, SLOT(sendSerialPortStatus(int)));
|
||||||
|
|
||||||
connect(m_sbgRecorder, SIGNAL(sbgSolutionModeSignal(int)),this, SLOT(sendSbgSolutionModeState(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(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)));
|
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程序
|
//当软件不正常关闭并且重启后,通知其他psdk程序
|
||||||
m_clientIpAddress=QHostAddress(QHostAddress::LocalHost);
|
m_clientIpAddress=QHostAddress(QHostAddress::LocalHost);
|
||||||
sendSerialPortStatus(0);
|
sendSerialPortStatus(0);
|
||||||
sendXimeaImageStatus(0);
|
sendXimeaImageStatus(100);
|
||||||
sendCopyFileStatus(0);
|
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;
|
std::cout<<"UdpServer::UdpServer--------:System ready!"<<std::endl;
|
||||||
}
|
}
|
||||||
@ -88,6 +112,10 @@ void UdpServer::processPendingDatagrams()
|
|||||||
case 1://启动系统: 打开sbg串口并采集数据,打开光谱仪
|
case 1://启动系统: 打开sbg串口并采集数据,打开光谱仪
|
||||||
{
|
{
|
||||||
std::cout<<"1代表启动系统!"<<std::endl;
|
std::cout<<"1代表启动系统!"<<std::endl;
|
||||||
|
|
||||||
|
system("sudo gpio write 10 1");
|
||||||
|
sleep(4);//睡眠4秒,等待电脑打开usb电源,以便给相机供电
|
||||||
|
|
||||||
emit systemStart();
|
emit systemStart();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -95,7 +123,7 @@ void UdpServer::processPendingDatagrams()
|
|||||||
case 2://关闭系统:关闭相机和sbg串口,关闭软件
|
case 2://关闭系统:关闭相机和sbg串口,关闭软件
|
||||||
{
|
{
|
||||||
std::cout<<"2代表关闭系统!"<<std::endl;
|
std::cout<<"2代表关闭系统!"<<std::endl;
|
||||||
|
m_300tcTemperature->stopRecordTemperature();
|
||||||
|
|
||||||
if(m_sbgRecorder->getSbgState()>=1)
|
if(m_sbgRecorder->getSbgState()>=1)
|
||||||
{
|
{
|
||||||
@ -110,31 +138,27 @@ void UdpServer::processPendingDatagrams()
|
|||||||
|
|
||||||
emit systemStop();
|
emit systemStop();
|
||||||
|
|
||||||
|
sleep(4);//睡眠4秒,等待
|
||||||
|
system("sudo gpio write 10 0");
|
||||||
|
|
||||||
//QCoreApplication::quit();
|
//QCoreApplication::quit();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3://系统开始采集高光谱影像
|
case 3://系统开始采集高光谱影像
|
||||||
{
|
{
|
||||||
//emit startRecordHyperspectralSignal();//真实的影像开始采集通过惯导中的信号(sbgReady)触发
|
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=103)
|
||||||
|
{
|
||||||
|
std::cout<<"3代表系统开始采集高光谱影像!"<<std::endl;
|
||||||
m_sbgRecorder->startRecordHyperspectral();
|
m_sbgRecorder->startRecordHyperspectral();
|
||||||
|
}
|
||||||
// if(m_sbgRecorder->getSbgState()==2)//开始采集前还需要判断相机的状态??????????????????????????????????????????
|
|
||||||
// {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// else if(m_sbgRecorder->getSbgState()==3)
|
|
||||||
// {
|
|
||||||
// std::cout<<"系统已经开始采集!"<<std::endl;
|
|
||||||
// }
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4://系统停止采集高光谱影像
|
case 4://系统停止采集高光谱影像
|
||||||
{
|
{
|
||||||
std::cout<<"4代表系统停止采集高光谱影像!"<<std::endl;
|
|
||||||
|
|
||||||
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=104)
|
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=104)
|
||||||
{
|
{
|
||||||
|
std::cout<<"4代表系统停止采集高光谱影像!"<<std::endl;
|
||||||
m_imager->stopRecord();
|
m_imager->stopRecord();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,17 +186,11 @@ void UdpServer::processPendingDatagrams()
|
|||||||
}
|
}
|
||||||
case 7:
|
case 7:
|
||||||
{
|
{
|
||||||
if(datagramList[1].toInt()==1)
|
if(m_imager->getImagerState()>=101 && m_imager->getImagerState()<=103)
|
||||||
{
|
{
|
||||||
std::cout<<"拷贝数据!"<<std::endl;
|
float time = datagramList[1].toFloat();//μs
|
||||||
|
m_imager->wrapSetExposureTime(time);
|
||||||
emit startCopyFileSignal();
|
std::cout<<"7,手动设置曝光时间为:" << time <<std::endl;
|
||||||
}
|
|
||||||
else if(datagramList[1].toInt()==0)
|
|
||||||
{
|
|
||||||
std::cout<<"删除数据!"<<std::endl;
|
|
||||||
|
|
||||||
emit startDeleteFileSignal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -200,8 +218,30 @@ void UdpServer::processPendingDatagrams()
|
|||||||
|
|
||||||
break;
|
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:
|
default:
|
||||||
std::cout<<">=9没有意义!"<<std::endl;
|
std::cout<<">=11没有意义!"<<std::endl;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -253,9 +293,9 @@ void UdpServer::sender(int status)
|
|||||||
|
|
||||||
void UdpServer::sendSerialPortStatus(int serialPortStatus)
|
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;
|
QByteArray datagram2send;
|
||||||
|
|
||||||
@ -263,11 +303,13 @@ void UdpServer::sendSerialPortStatus(int serialPortStatus)
|
|||||||
|
|
||||||
datagram2send.operator =(status.toStdString().c_str());
|
datagram2send.operator =(status.toStdString().c_str());
|
||||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||||
|
|
||||||
|
stateOf300tc.setSbgState(serialPortStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UdpServer::sendSbgSolutionModeState(int SolutionMode)
|
void UdpServer::sendSbgSolutionModeState(int SolutionMode)
|
||||||
{
|
{
|
||||||
std::cout<<"UdpServer::sendSbgSolutionModeState---------------------:"<< SolutionMode <<std::endl;
|
// std::cout<<"UdpServer::sendSbgSolutionModeState---------------------:"<< SolutionMode <<std::endl;
|
||||||
|
|
||||||
QByteArray datagram2send;
|
QByteArray datagram2send;
|
||||||
|
|
||||||
@ -275,15 +317,17 @@ void UdpServer::sendSbgSolutionModeState(int SolutionMode)
|
|||||||
|
|
||||||
datagram2send.operator =(status.toStdString().c_str());
|
datagram2send.operator =(status.toStdString().c_str());
|
||||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
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;
|
// std::cout<<"UdpServer::sendSbgAccuracyState---------------------:"<< Accuracy <<std::endl;
|
||||||
|
|
||||||
QByteArray datagram2send;
|
QByteArray datagram2send;
|
||||||
|
|
||||||
QString status = "Accuracy," + QString::number(Accuracy);
|
QString status = "Accuracy," + QString::number(Accuracy) + "," + QString::number(SatelliteCounter);
|
||||||
|
|
||||||
datagram2send.operator =(status.toStdString().c_str());
|
datagram2send.operator =(status.toStdString().c_str());
|
||||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
||||||
@ -291,7 +335,7 @@ void UdpServer::sendSbgAccuracyState(int Accuracy)
|
|||||||
|
|
||||||
void UdpServer::sendXimeaImageStatus(int ximeaImageStatus)
|
void UdpServer::sendXimeaImageStatus(int ximeaImageStatus)
|
||||||
{
|
{
|
||||||
std::cout<<"UdpServer::sendXimeaImageStatus---------------------:"<< ximeaImageStatus <<std::endl;
|
// std::cout<<"UdpServer::sendXimeaImageStatus---------------------:"<< ximeaImageStatus <<std::endl;
|
||||||
|
|
||||||
QByteArray datagram2send;
|
QByteArray datagram2send;
|
||||||
|
|
||||||
@ -299,11 +343,54 @@ void UdpServer::sendXimeaImageStatus(int ximeaImageStatus)
|
|||||||
|
|
||||||
datagram2send.operator =(status.toStdString().c_str());
|
datagram2send.operator =(status.toStdString().c_str());
|
||||||
m_udpSocket->writeDatagram(datagram2send.data(),datagram2send.size(),m_clientIpAddress, 45455);
|
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)
|
void UdpServer::sendCopyFileStatus(int fileStatus)
|
||||||
{
|
{
|
||||||
std::cout<<"UdpServer::sendCopyFileStatus---------------------:"<< fileStatus <<std::endl;
|
// std::cout<<"UdpServer::sendCopyFileStatus---------------------:"<< fileStatus <<std::endl;
|
||||||
|
|
||||||
QByteArray datagram2send;
|
QByteArray datagram2send;
|
||||||
|
|
||||||
@ -317,3 +404,199 @@ void UdpServer::onRecordFinished()
|
|||||||
{
|
{
|
||||||
std::cout<<"UdpServer::onRecordFinished----------------:影像停止采集"<<std::endl;
|
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 "Header_Files/utility_tc.h"
|
||||||
#include <QDir>
|
#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()
|
QString getFileNameBaseOnTime()
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -69,3 +88,36 @@ void swap(unsigned short * a, unsigned short * b)
|
|||||||
*a=*b;
|
*a=*b;
|
||||||
*b=tmp;
|
*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