第一次提交:
1、继承resonon相机库虚类(imager_base.h),实现了控制ximea相机的控制类库; 2、在ximea相机控制类(irisximeaimager.h)中,加入了定制的7个函数(setGainOffset、setRoi等等);
This commit is contained in:
83
.gitignore
vendored
Normal file
83
.gitignore
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
# tc
|
||||
/.idea/*
|
||||
/build/*
|
||||
|
||||
|
||||
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
27
CMakeLists.txt
Normal file
27
CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(irisXimeaImager)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
SET(CMAKE_INSTALL_PREFIX < /home/pi/bin >)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
set(QT Core Network SerialPort)
|
||||
set(TEMPLATE app)
|
||||
set(TARGET irisXimeaImager)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
find_package(Qt5 REQUIRED ${QT})
|
||||
|
||||
add_library(
|
||||
irisXimeaImager SHARED
|
||||
Source_Files/imager_base.cpp
|
||||
Header_Files/imager_base.h
|
||||
Source_Files/irisximeaimager.cpp
|
||||
Header_Files/irisximeaimager.h
|
||||
Header_Files/irisximeaimager_global.h
|
||||
)
|
||||
|
||||
qt5_use_modules(irisXimeaImager ${QT})
|
||||
|
||||
target_link_libraries(irisXimeaImager m3api)
|
93
Header_Files/imager_base.h
Normal file
93
Header_Files/imager_base.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Iris API
|
||||
*
|
||||
* By using this API, the user agrees to the terms and conditions as stated in the
|
||||
* document "Terms of Use", located on the Resonon website
|
||||
* at: http://www.resonon.com/downloads/Resonon_API_Terms_of_Use.pdf.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GUARD_Iris_IMAGER_BASE_H
|
||||
#define __GUARD_Iris_IMAGER_BASE_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include <cstdint>
|
||||
#include "irisximeaimager_global.h"
|
||||
|
||||
/**
|
||||
* The Iris namespace contains all public classes.
|
||||
*/
|
||||
namespace Iris
|
||||
{
|
||||
/**
|
||||
* An abstract base class which provides a common interface for all imagers.
|
||||
*/
|
||||
class IRISXIMEAIMAGERSHARED_EXPORT ImagerBase
|
||||
{
|
||||
public:
|
||||
ImagerBase();
|
||||
virtual ~ImagerBase();
|
||||
|
||||
|
||||
virtual void connect(const char * camera_sn=NULL)=0;
|
||||
virtual void disconnect()=0;
|
||||
virtual void start()=0;
|
||||
virtual void stop()=0;
|
||||
virtual void get_imager_type(char *buffer, int buffer_size)=0;
|
||||
virtual void get_serial_number(char *buffer, int buffer_size)=0;
|
||||
virtual void get_camera_serial_number(char *buffer, int buffer_size)=0;
|
||||
virtual void generate_configuration_report(char *buffer, int buffer_size)=0;
|
||||
virtual float get_coeff_a()=0;
|
||||
virtual float get_coeff_b()=0;
|
||||
virtual float get_coeff_c()=0;
|
||||
virtual double get_wavelength_at_band(const int band)=0;
|
||||
int get_nearest_band_to_wavelength(const double wavelength);
|
||||
virtual int get_frame_buffer_size_in_bytes()=0;
|
||||
virtual unsigned short* get_frame(unsigned short* buffer)=0;
|
||||
virtual std::uint64_t get_last_timestamp()=0;
|
||||
virtual std::uint64_t ticks_per_second()=0;
|
||||
virtual void set_spectral_bin(int new_spectral_bin);
|
||||
virtual int get_spectral_bin();
|
||||
virtual int get_min_spectral_bin();
|
||||
virtual int get_max_spectral_bin();
|
||||
virtual int get_band_count()=0;
|
||||
virtual int get_start_band();
|
||||
virtual void set_start_band(int band);
|
||||
virtual int get_min_start_band();
|
||||
virtual int get_max_start_band();
|
||||
virtual int get_inc_start_band();
|
||||
virtual int get_end_band();
|
||||
virtual void set_end_band(int band);
|
||||
virtual int get_min_end_band();
|
||||
virtual int get_max_end_band();
|
||||
virtual int get_inc_end_band();
|
||||
virtual int get_sample_count()=0;
|
||||
virtual int get_start_sample();
|
||||
virtual void set_start_sample(int sample);
|
||||
virtual int get_min_start_sample();
|
||||
virtual int get_max_start_sample();
|
||||
virtual int get_inc_start_sample();
|
||||
virtual int get_end_sample();
|
||||
virtual void set_end_sample(int sample);
|
||||
virtual int get_min_end_sample();
|
||||
virtual int get_max_end_sample();
|
||||
virtual int get_inc_end_sample();
|
||||
virtual void set_framerate(const double frames_per_second)=0;
|
||||
virtual double get_framerate()=0;
|
||||
virtual double get_min_framerate()=0;
|
||||
virtual double get_max_framerate()=0;
|
||||
virtual double get_min_integration_time()=0;
|
||||
virtual double get_max_integration_time()=0;
|
||||
virtual void set_integration_time(const double milliseconds)=0;
|
||||
virtual double get_integration_time()=0;
|
||||
virtual void set_gain(const double gain);
|
||||
virtual double get_gain();
|
||||
virtual double get_min_gain();
|
||||
virtual double get_max_gain();
|
||||
virtual void set_internal_trigger();
|
||||
virtual void set_external_trigger(unsigned int signal_line, bool rising_edge=true);
|
||||
virtual bool is_trigger_external();
|
||||
};
|
||||
} //end namespace Iris
|
||||
#endif //end ifndef __GUARD_Iris_IMAGER_BASE_H
|
104
Header_Files/irisximeaimager.h
Normal file
104
Header_Files/irisximeaimager.h
Normal file
@ -0,0 +1,104 @@
|
||||
#ifndef IRISXIMEAIMAGER_H
|
||||
#define IRISXIMEAIMAGER_H
|
||||
|
||||
#include <memory.h>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
|
||||
#include "irisximeaimager_global.h"
|
||||
#include "imager_base.h"
|
||||
#ifdef WIN32
|
||||
#include <xiApi.h> // Windows
|
||||
#else
|
||||
#include <m3api/xiApi.h> // Linux, OSX
|
||||
#endif
|
||||
|
||||
#define CE(func) {XI_RETURN stat = (func); if (XI_OK!=stat) {printf("Error:%d returned from function:"#func"\n",stat);throw stat;}}
|
||||
#define HandleResult(res,place) if (res!=XI_OK) {printf("Error after %s (%d)\n",place,res);}
|
||||
|
||||
namespace Iris
|
||||
{
|
||||
class IRISXIMEAIMAGERSHARED_EXPORT IrisXimeaImager:public ImagerBase
|
||||
{
|
||||
public:
|
||||
HANDLE m_xiH;
|
||||
void setGainOffset(float gain, float offset);
|
||||
bool setSpectralBin(int spectralBin);
|
||||
bool setSpatialBin(int spatialBin);
|
||||
int getSpectralBin();
|
||||
int getSpatialBin();
|
||||
void setRoi(int OffsetX, int width, int OffsetY, int height);
|
||||
int getBufferSizeOfOneFrame();
|
||||
public:
|
||||
float m_fGain;
|
||||
float m_fOffset;
|
||||
|
||||
//继承基类的
|
||||
IrisXimeaImager();//11111111111111111111
|
||||
virtual ~IrisXimeaImager();
|
||||
|
||||
void connect(const char * camera_serial_number=NULL);//111111111111111111111111111111111
|
||||
void disconnect();//111111111111111111111111111111
|
||||
void start();//111111111111111111111
|
||||
void stop();//1111111111111111111111
|
||||
void get_imager_type(char *buffer, int buffer_size);
|
||||
void get_serial_number(char *buffer, int buffer_size);
|
||||
void get_camera_serial_number(char *buffer, int buffer_size);
|
||||
void generate_configuration_report(char *buffer, int buffer_size);
|
||||
float get_coeff_a();
|
||||
float get_coeff_b();
|
||||
float get_coeff_c();
|
||||
double get_wavelength_at_band(const int band);//11111111111111111111
|
||||
int get_frame_buffer_size_in_bytes();
|
||||
unsigned short* get_frame(unsigned short* buffer);//11111111111111111111111
|
||||
std::uint64_t get_last_timestamp();
|
||||
std::uint64_t ticks_per_second();
|
||||
void set_spectral_bin(int new_spectral_bin);//11111111111111111111111111111111
|
||||
int get_spectral_bin();
|
||||
int get_min_spectral_bin();
|
||||
int get_max_spectral_bin();
|
||||
int get_band_count();//11111111111111111111
|
||||
int get_start_band();//对应上一版本api的函数:get_window_start_band
|
||||
void set_start_band(int band);
|
||||
int get_min_start_band();
|
||||
int get_max_start_band();
|
||||
int get_inc_start_band();
|
||||
int get_end_band();//对应上一版本api的函数:get_window_end_band
|
||||
void set_end_band(int band);
|
||||
int get_min_end_band();
|
||||
int get_max_end_band();
|
||||
int get_inc_end_band();
|
||||
int get_sample_count();//11111111111111111
|
||||
int get_start_sample();
|
||||
void set_start_sample(int sample);
|
||||
int get_min_start_sample();
|
||||
int get_max_start_sample();
|
||||
int get_inc_start_sample();
|
||||
int get_end_sample();
|
||||
void set_end_sample(int sample);
|
||||
int get_min_end_sample();
|
||||
int get_max_end_sample();
|
||||
int get_inc_end_sample();
|
||||
void set_framerate(const double frames_per_second);//11111111111111111111111111111111
|
||||
double get_framerate();//1111111111111111111111
|
||||
double get_min_framerate();
|
||||
double get_max_framerate();
|
||||
double get_min_integration_time();
|
||||
double get_max_integration_time();
|
||||
void set_integration_time(const double microsecond);//111111111111111111111
|
||||
double get_integration_time();//1111111111111111111111111111111
|
||||
void set_gain(const double gain);//111111111111
|
||||
double get_gain();//111111111111
|
||||
double get_min_gain();
|
||||
double get_max_gain();
|
||||
void set_internal_trigger();
|
||||
void set_external_trigger(unsigned int signal_line, bool rising_edge=true);
|
||||
bool is_trigger_external();
|
||||
protected:
|
||||
private:
|
||||
XI_IMG m_image; // image buffer
|
||||
uint64_t m_timestampOfCamera;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // IRISXIMEAIMAGER_H
|
12
Header_Files/irisximeaimager_global.h
Normal file
12
Header_Files/irisximeaimager_global.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef IRISXIMEAIMAGER_GLOBAL_H
|
||||
#define IRISXIMEAIMAGER_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(IRISXIMEAIMAGER_LIBRARY)
|
||||
# define IRISXIMEAIMAGERSHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define IRISXIMEAIMAGERSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // IRISXIMEAIMAGER_GLOBAL_H
|
44
IrisXimeaImager.pro
Normal file
44
IrisXimeaImager.pro
Normal file
@ -0,0 +1,44 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2021-04-08T14:35:26
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT -= gui
|
||||
|
||||
TARGET = IrisXimeaImager
|
||||
TEMPLATE = lib
|
||||
|
||||
DEFINES += IRISXIMEAIMAGER_LIBRARY
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which as been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
irisximeaimager.cpp \
|
||||
imager_base.cpp
|
||||
|
||||
HEADERS += \
|
||||
irisximeaimager.h \
|
||||
irisximeaimager_global.h \
|
||||
imager_base.h
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
INSTALLS += target
|
||||
}
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../usr/lib/release/ -lm3api
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../usr/lib/debug/ -lm3api
|
||||
else:unix: LIBS += -L$$PWD/../../../../usr/lib/ -lm3api
|
||||
|
||||
INCLUDEPATH += $$PWD/../../../../usr/include
|
||||
DEPENDPATH += $$PWD/../../../../usr/include
|
165
Source_Files/imager_base.cpp
Normal file
165
Source_Files/imager_base.cpp
Normal file
@ -0,0 +1,165 @@
|
||||
#include "Header_Files/imager_base.h"
|
||||
Iris::ImagerBase::ImagerBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Iris::ImagerBase::~ImagerBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_spectral_bin(int new_spectral_bin)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_spectral_bin()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_min_spectral_bin()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_max_spectral_bin()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_start_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_start_band(int band)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_min_start_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_max_start_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_inc_start_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_end_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_end_band(int band)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_min_end_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_max_end_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_inc_end_band()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_start_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_start_sample(int sample)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_min_start_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_max_start_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_inc_start_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_end_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_end_sample(int sample)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_min_end_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_max_end_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Iris::ImagerBase::get_inc_end_sample()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_gain(const double gain)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
double Iris::ImagerBase::get_gain()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
double Iris::ImagerBase::get_min_gain()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
double Iris::ImagerBase::get_max_gain()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_internal_trigger()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::ImagerBase::set_external_trigger(unsigned int signal_line, bool rising_edge)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Iris::ImagerBase::is_trigger_external()
|
||||
{
|
||||
return true;
|
||||
}
|
462
Source_Files/irisximeaimager.cpp
Normal file
462
Source_Files/irisximeaimager.cpp
Normal file
@ -0,0 +1,462 @@
|
||||
#include "Header_Files/irisximeaimager.h"
|
||||
|
||||
void Iris::IrisXimeaImager::setGainOffset(float gain, float offset)
|
||||
{
|
||||
m_fGain = gain;
|
||||
m_fOffset = offset;
|
||||
}
|
||||
|
||||
bool Iris::IrisXimeaImager::setSpectralBin(int spectralBin)
|
||||
{
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_SELECTOR, XI_BIN_SELECT_HOST_CPU));//用:XI_BIN_SELECT_HOST_CPU;默认为XI_BIN_SELECT_SENSOR(会报错),不可用:XI_BIN_SELECT_DEVICE_FPGA
|
||||
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL_MODE, XI_BIN_MODE_SUM));
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL, spectralBin));//***********************************
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Iris::IrisXimeaImager::setSpatialBin(int spatialBin)
|
||||
{
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_SELECTOR, XI_BIN_SELECT_HOST_CPU));//用:XI_BIN_SELECT_HOST_CPU;默认为XI_BIN_SELECT_SENSOR(会报错),不可用:XI_BIN_SELECT_DEVICE_FPGA
|
||||
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL_MODE, XI_BIN_MODE_SUM));
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL, spatialBin));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::getSpectralBin()
|
||||
{
|
||||
int spectralBin = 0;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL, &spectralBin));
|
||||
|
||||
return spectralBin;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::getSpatialBin()
|
||||
{
|
||||
int spatialBin = 0;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL, &spatialBin));
|
||||
|
||||
return spatialBin;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::setRoi(int OffsetX, int width, int OffsetY, int height)
|
||||
{
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_WIDTH, width));
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_OFFSET_X, OffsetX));
|
||||
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_HEIGHT, height));
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_OFFSET_Y, OffsetY));
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::getBufferSizeOfOneFrame()
|
||||
{
|
||||
if(m_xiH==NULL)
|
||||
return 0;
|
||||
|
||||
start();
|
||||
|
||||
//清空image缓存
|
||||
memset(&m_image, 0, sizeof(m_image));
|
||||
m_image.size = sizeof(XI_IMG);
|
||||
|
||||
CE(xiGetImage(m_xiH, 5000, &m_image)); // getting next image from the camera opened
|
||||
|
||||
stop();
|
||||
|
||||
return static_cast<int>(m_image.bp_size);
|
||||
}
|
||||
|
||||
Iris::IrisXimeaImager::IrisXimeaImager()
|
||||
{
|
||||
m_xiH=NULL;
|
||||
}
|
||||
|
||||
Iris::IrisXimeaImager::~IrisXimeaImager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::connect(const char *camera_serial_number)
|
||||
{
|
||||
printf("Iris::IrisXimeaImager::connect----1 打开相机(xiOpenDevice)\n");
|
||||
CE(xiOpenDevice(0, &m_xiH));//没有插上ximea相机,这句代码都过不去
|
||||
|
||||
//设置数据格式
|
||||
printf("Iris::IrisXimeaImager::connect----2 设置数据格式(xiSetParamInt)\n");
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_IMAGE_DATA_FORMAT, XI_RAW16));//Default value: XI_MONO8
|
||||
// //设置packing, 使用xiGetImage接收影像时不执行unpacking
|
||||
// CE(xiSetParamInt(m_xiH, XI_PRM_OUTPUT_DATA_BIT_DEPTH, 12));//set 12 bit transport data width
|
||||
// CE(xiSetParamInt(m_xiH, XI_PRM_OUTPUT_DATA_PACKING, XI_ON));//enable packing
|
||||
// //使用xiGetImage接收影像时不执行unpacking
|
||||
// CE(xiSetParamInt(m_xiH, XI_PRM_IMAGE_DATA_FORMAT, XI_FRM_TRANSPORT_DATA));//in this case, the function xiGetImage just set pointer to transport-buffer without any processing
|
||||
|
||||
//判断数据格式设置是否成功
|
||||
int dataFortmat;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_IMAGE_DATA_FORMAT, &dataFortmat));
|
||||
if(dataFortmat==XI_RAW16)
|
||||
{
|
||||
printf("Iris::IrisXimeaImager::connect----当前数据格式设置成功, 设置为: XI_RAW16\n");
|
||||
}
|
||||
else if(dataFortmat==XI_FRM_TRANSPORT_DATA)
|
||||
{
|
||||
printf("Iris::IrisXimeaImager::connect----当前数据格式设置成功, 设置为: XI_FRM_TRANSPORT_DATA\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Iris::IrisXimeaImager::connect----2 数据格式设置失败!\n");
|
||||
printf("Iris::IrisXimeaImager::connect----当前数据格式为:%d\n",dataFortmat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::disconnect()
|
||||
{
|
||||
printf("Closing camera...\n");
|
||||
CE(xiCloseDevice(m_xiH));
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::start()
|
||||
{
|
||||
CE(xiStartAcquisition(m_xiH));
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::stop()
|
||||
{
|
||||
//printf("Stopping acquisition...\n");
|
||||
CE(xiStopAcquisition(m_xiH));
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::get_imager_type(char *buffer, int buffer_size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::get_serial_number(char *buffer, int buffer_size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::get_camera_serial_number(char *buffer, int buffer_size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::generate_configuration_report(char *buffer, int buffer_size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
float Iris::IrisXimeaImager::get_coeff_a()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Iris::IrisXimeaImager::get_coeff_b()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Iris::IrisXimeaImager::get_coeff_c()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_wavelength_at_band(const int band)
|
||||
{
|
||||
//sn008
|
||||
float a=1.999564;
|
||||
float b=-279.893;
|
||||
//
|
||||
float wavelength=band*m_fGain + m_fOffset;
|
||||
return wavelength;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_frame_buffer_size_in_bytes()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned short *Iris::IrisXimeaImager::get_frame(unsigned short *buffer)
|
||||
{
|
||||
//清空image缓存
|
||||
memset(&m_image, 0, sizeof(m_image));
|
||||
m_image.size = sizeof(XI_IMG);
|
||||
|
||||
// //Reads the current timestamp value from camera in nanoseconds.
|
||||
// m_timestampOfCamera=0;
|
||||
// DWORD size=sizeof(m_timestampOfCamera);
|
||||
// XI_PRM_TYPE type=xiTypeInteger64;
|
||||
// xiGetParam(m_xiH, XI_PRM_TIMESTAMP,&m_timestampOfCamera,&size,&type);
|
||||
|
||||
CE(xiGetImage(m_xiH, 5000, &m_image)); // getting next image from the camera opened
|
||||
|
||||
|
||||
// int buffer_policy=0;//
|
||||
// xiGetParamInt(m_xiH, XI_PRM_BUFFER_POLICY,&buffer_policy);
|
||||
//// XI_BP_UNSAFE =0, // User gets pointer to internally allocated circle buffer and data may be overwritten by device.
|
||||
//// XI_BP_SAFE =1, // Data from device will be copied to user allocated buffer or xiApi allocated memory.
|
||||
//
|
||||
//
|
||||
// int b1=m_image.width*m_image.height*2;
|
||||
// int b2=m_image.size;//结构体XI_IMG的大小
|
||||
int b3=m_image.bp_size;//一般b1==b3
|
||||
// int b4=0;
|
||||
// xiGetParamInt(m_xiH, XI_PRM_IMAGE_PAYLOAD_SIZE,&b4);
|
||||
|
||||
|
||||
// std::cout<<"b1="<<b1<<std::endl;
|
||||
// std::cout<<"b2="<<b2<<std::endl;
|
||||
// std::cout<<"b3="<<b3<<std::endl;
|
||||
// std::cout<<"b4="<<b4<<std::endl;
|
||||
// std::cout<<"buffer_policy="<<buffer_policy<<std::endl;
|
||||
|
||||
|
||||
//方法1:memcpy
|
||||
memcpy(buffer,m_image.bp,b3);//*2是因为memcpy拷贝的单位是字节数
|
||||
// //方法2:此做法是错误的,虽然是指针,也是传值!
|
||||
// buffer = (unsigned short *)m_image.bp;
|
||||
|
||||
//强制将指针从高精度(uint64_t*)转换到低精度(unsigned short *),会有精度降低的问题???????????????????????????????????????????????????
|
||||
return (unsigned short *)&m_timestampOfCamera;
|
||||
}
|
||||
|
||||
uint64_t Iris::IrisXimeaImager::get_last_timestamp()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t Iris::IrisXimeaImager::ticks_per_second()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_spectral_bin(int new_spectral_bin)
|
||||
{
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_SELECTOR, XI_BIN_SELECT_HOST_CPU));//用:XI_BIN_SELECT_HOST_CPU;默认为XI_BIN_SELECT_SENSOR(会报错),不可用:XI_BIN_SELECT_DEVICE_FPGA
|
||||
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL_MODE, XI_BIN_MODE_SUM));
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_VERTICAL, new_spectral_bin));
|
||||
|
||||
// CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL_MODE, XI_BIN_MODE_SUM));
|
||||
// CE(xiSetParamInt(m_xiH, XI_PRM_BINNING_HORIZONTAL, x));
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_spectral_bin()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_min_spectral_bin()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_max_spectral_bin()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_band_count()
|
||||
{
|
||||
int height;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_HEIGHT, &height));
|
||||
return height;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_start_band()
|
||||
{
|
||||
int WindowStartLine;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_OFFSET_Y, &WindowStartLine));
|
||||
|
||||
return WindowStartLine;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_start_band(int band)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_min_start_band()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_max_start_band()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_inc_start_band()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_end_band()
|
||||
{
|
||||
int height;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_HEIGHT, &height));
|
||||
return get_start_band()+height;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_end_band(int band)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_min_end_band()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_max_end_band()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_inc_end_band()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_sample_count()
|
||||
{
|
||||
int width;
|
||||
CE(xiGetParamInt(m_xiH, XI_PRM_WIDTH, &width));
|
||||
return width;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_start_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_start_sample(int sample)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_min_start_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_max_start_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_inc_start_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_end_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_end_sample(int sample)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_min_end_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_max_end_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Iris::IrisXimeaImager::get_inc_end_sample()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_framerate(const double frames_per_second)
|
||||
{
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_ACQ_TIMING_MODE, XI_ACQ_TIMING_MODE_FRAME_RATE_LIMIT));
|
||||
|
||||
CE(xiSetParamFloat(m_xiH, XI_PRM_FRAMERATE, frames_per_second));
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_framerate()
|
||||
{
|
||||
float framerate;
|
||||
CE(xiGetParamFloat(m_xiH, XI_PRM_FRAMERATE, &framerate));
|
||||
return framerate;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_min_framerate()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_max_framerate()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_min_integration_time()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_max_integration_time()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_integration_time(const double microsecond)
|
||||
{
|
||||
CE(xiSetParamInt(m_xiH, XI_PRM_EXPOSURE, microsecond));//time_in_us(microseconds)
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_integration_time()
|
||||
{
|
||||
float exposureTime;
|
||||
CE(xiGetParamFloat(m_xiH, XI_PRM_EXPOSURE, &exposureTime));//time_in_us(microseconds)
|
||||
return exposureTime;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_gain(const double gain)
|
||||
{
|
||||
CE(xiSetParamFloat(m_xiH, XI_PRM_GAIN, gain));//gain_in_db
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_gain()
|
||||
{
|
||||
float gain;
|
||||
CE(xiGetParamFloat(m_xiH, XI_PRM_GAIN, &gain));
|
||||
return gain;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_min_gain()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double Iris::IrisXimeaImager::get_max_gain()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_internal_trigger()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Iris::IrisXimeaImager::set_external_trigger(unsigned int signal_line, bool rising_edge)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Iris::IrisXimeaImager::is_trigger_external()
|
||||
{
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user