feat: v0.1.0更新
This commit is contained in:
17
include/1225pc_viewer.h
Normal file
17
include/1225pc_viewer.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
// 初始化显示模块(内部创建线程)
|
||||
bool pc_viewer_start();
|
||||
|
||||
// 停止显示模块
|
||||
void pc_viewer_stop();
|
||||
|
||||
// 推送一帧 XYZ 数据(float,xyzxyz...)
|
||||
// 只显示最新一帧,旧数据会被覆盖
|
||||
void pc_viewer_update(
|
||||
const float* xyz,
|
||||
size_t point_count,
|
||||
uint32_t block_id
|
||||
);
|
||||
42
include/1225raw_image_viewer.h
Normal file
42
include/1225raw_image_viewer.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef RAW_IMAGE_VIEWER_H
|
||||
#define RAW_IMAGE_VIEWER_H
|
||||
|
||||
// 防止C/C++混合调用时的名称修饰问题
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// 引入必要的标准类型声明(保证参数类型可识别)
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* @brief 启动RAW图像可视化线程(初始化+启动后台刷新)
|
||||
* @return bool 启动成功返回true,失败返回false
|
||||
*/
|
||||
bool raw_image_viewer_start();
|
||||
|
||||
/**
|
||||
* @brief 停止RAW图像可视化线程(安全退出+资源清理)
|
||||
*/
|
||||
void raw_image_viewer_stop();
|
||||
|
||||
/**
|
||||
* @brief 更新RAW图像数据(线程安全,与后台可视化线程解耦)
|
||||
* @param data 16位RAW图像数据指针(不可修改)
|
||||
* @param width 图像宽度(必须>0)
|
||||
* @param height 图像高度(必须>0)
|
||||
* @param block_id 当前图像块ID(用于窗口标题显示)
|
||||
*/
|
||||
void raw_image_viewer_update(const uint16_t* data, int width, int height, uint32_t block_id);
|
||||
|
||||
/**
|
||||
* @brief 清理RAW图像可视化相关资源(兼容原接口,可选调用)
|
||||
* @details 内部会先调用raw_image_viewer_stop(),再释放图像缓存内存
|
||||
*/
|
||||
void raw_image_viewer_cleanup();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // RAW_IMAGE_VIEWER_H
|
||||
121
include/core/GVSPParser.h
Normal file
121
include/core/GVSPParser.h
Normal file
@@ -0,0 +1,121 @@
|
||||
#ifndef GVSPPARSER_H
|
||||
#define GVSPPARSER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QImage>
|
||||
#include <cstdint>
|
||||
|
||||
// GVSP packet types
|
||||
#define GVSP_LEADER_PACKET 0x01
|
||||
#define GVSP_PAYLOAD_PACKET 0x02
|
||||
#define GVSP_TRAILER_PACKET 0x03
|
||||
|
||||
// Payload types
|
||||
#define PAYLOAD_TYPE_IMAGE 0x0001
|
||||
#define PAYLOAD_TYPE_BINARY 0x0003
|
||||
|
||||
// Image format
|
||||
#define PIXEL_FORMAT_12BIT_GRAY 0x010C0001
|
||||
|
||||
// Image dimensions
|
||||
#define IMAGE_WIDTH 1224
|
||||
#define IMAGE_HEIGHT 1024
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
// GVSP packet header
|
||||
struct GVSPPacketHeader {
|
||||
uint16_t status;
|
||||
uint16_t block_id;
|
||||
uint32_t packet_fmt_id;
|
||||
};
|
||||
|
||||
// Image data leader
|
||||
struct GVSPImageDataLeader {
|
||||
uint16_t reserved;
|
||||
uint16_t payload_type;
|
||||
uint32_t timestamp_high;
|
||||
uint32_t timestamp_low;
|
||||
uint32_t pixel_format;
|
||||
uint32_t size_x;
|
||||
uint32_t size_y;
|
||||
uint32_t offset_x;
|
||||
uint32_t offset_y;
|
||||
uint16_t padding_x;
|
||||
uint16_t padding_y;
|
||||
};
|
||||
|
||||
// Image data trailer
|
||||
struct GVSPImageDataTrailer {
|
||||
uint32_t reserved;
|
||||
uint16_t payload_type;
|
||||
uint32_t size_y;
|
||||
};
|
||||
|
||||
// Binary data leader (for depth data)
|
||||
struct GVSPBinaryDataLeader {
|
||||
uint16_t reserved;
|
||||
uint16_t payload_type;
|
||||
uint32_t timestamp_high;
|
||||
uint32_t timestamp_low;
|
||||
uint32_t file_size;
|
||||
uint32_t name_len;
|
||||
char file_name[256];
|
||||
};
|
||||
|
||||
// Binary data trailer
|
||||
struct GVSPBinaryDataTrailer {
|
||||
uint32_t reserved;
|
||||
uint16_t payload_type;
|
||||
uint32_t checksum;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
class GVSPParser : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GVSPParser(QObject *parent = nullptr);
|
||||
~GVSPParser();
|
||||
|
||||
void parsePacket(const QByteArray &packet);
|
||||
void reset();
|
||||
|
||||
signals:
|
||||
void imageReceived(const QImage &image, uint32_t blockId);
|
||||
void depthDataReceived(const QByteArray &depthData, uint32_t blockId);
|
||||
void parseError(const QString &error);
|
||||
|
||||
private:
|
||||
void handleLeaderPacket(const uint8_t *data, size_t size);
|
||||
void handlePayloadPacket(const uint8_t *data, size_t size);
|
||||
void handleTrailerPacket(const uint8_t *data, size_t size);
|
||||
|
||||
void processImageData();
|
||||
void processDepthData();
|
||||
|
||||
private:
|
||||
// Reception state
|
||||
bool m_isReceiving;
|
||||
int m_dataType; // 0=unknown, 1=image, 3=depth
|
||||
uint32_t m_currentBlockId;
|
||||
|
||||
// Data buffer
|
||||
QByteArray m_dataBuffer;
|
||||
size_t m_expectedSize;
|
||||
size_t m_receivedSize;
|
||||
|
||||
// Image info
|
||||
uint32_t m_imageWidth;
|
||||
uint32_t m_imageHeight;
|
||||
uint32_t m_pixelFormat;
|
||||
|
||||
// Statistics
|
||||
uint32_t m_lastBlockId;
|
||||
int m_packetCount;
|
||||
};
|
||||
|
||||
#endif // GVSPPARSER_H
|
||||
41
include/core/Logger.h
Normal file
41
include/core/Logger.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef LOGGER_H
|
||||
#define LOGGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QMutex>
|
||||
|
||||
class Logger : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static Logger* instance();
|
||||
|
||||
void setLogFile(const QString &filePath);
|
||||
void setMaxLines(int maxLines);
|
||||
|
||||
void log(const QString &message);
|
||||
void debug(const QString &message);
|
||||
void info(const QString &message);
|
||||
void warning(const QString &message);
|
||||
void error(const QString &message);
|
||||
|
||||
private:
|
||||
explicit Logger(QObject *parent = nullptr);
|
||||
~Logger();
|
||||
|
||||
void writeLog(const QString &level, const QString &message);
|
||||
void checkAndTrimLog();
|
||||
|
||||
static Logger *s_instance;
|
||||
|
||||
QString m_logFilePath;
|
||||
int m_maxLines;
|
||||
QMutex m_mutex;
|
||||
int m_currentLines;
|
||||
};
|
||||
|
||||
#endif // LOGGER_H
|
||||
64
include/core/PointCloudProcessor.h
Normal file
64
include/core/PointCloudProcessor.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef POINTCLOUDPROCESSOR_H
|
||||
#define POINTCLOUDPROCESSOR_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <pcl/point_cloud.h>
|
||||
#include <pcl/point_types.h>
|
||||
#include <CL/cl.h>
|
||||
|
||||
class PointCloudProcessor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PointCloudProcessor(QObject *parent = nullptr);
|
||||
~PointCloudProcessor();
|
||||
|
||||
// 初始化OpenCL
|
||||
bool initializeOpenCL();
|
||||
|
||||
// 设置相机内参
|
||||
void setCameraIntrinsics(float fx, float fy, float cx, float cy);
|
||||
|
||||
// 设置Z缩放因子
|
||||
void setZScaleFactor(float scale);
|
||||
|
||||
// 将深度数据转换为点云(使用OpenCL GPU加速)
|
||||
void processDepthData(const QByteArray &depthData, uint32_t blockId);
|
||||
|
||||
signals:
|
||||
void pointCloudReady(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud, uint32_t blockId);
|
||||
void errorOccurred(const QString &error);
|
||||
|
||||
private:
|
||||
// 清理OpenCL资源
|
||||
void cleanupOpenCL();
|
||||
|
||||
// 相机内参
|
||||
float m_fx;
|
||||
float m_fy;
|
||||
float m_cx;
|
||||
float m_cy;
|
||||
|
||||
// Z缩放因子
|
||||
float m_zScale;
|
||||
|
||||
// 图像尺寸
|
||||
int m_imageWidth;
|
||||
int m_imageHeight;
|
||||
int m_totalPoints;
|
||||
|
||||
// OpenCL资源
|
||||
cl_platform_id m_platform;
|
||||
cl_device_id m_device;
|
||||
cl_context m_context;
|
||||
cl_command_queue m_queue;
|
||||
cl_program m_program;
|
||||
cl_kernel m_kernel;
|
||||
cl_mem m_depthBuffer;
|
||||
cl_mem m_xyzBuffer;
|
||||
bool m_clInitialized;
|
||||
};
|
||||
|
||||
#endif // POINTCLOUDPROCESSOR_H
|
||||
143
include/dkam_asyncqueue.h
Normal file
143
include/dkam_asyncqueue.h
Normal file
@@ -0,0 +1,143 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#ifdef _WIN32
|
||||
//Head files that WIN Visual Studio needs
|
||||
#include <tchar.h>
|
||||
#include <synchapi.h>
|
||||
|
||||
#else
|
||||
//Head files that linux system needs
|
||||
//TRUE FALSE BOOL that linux not support
|
||||
#include <pthread.h>
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define BOOL _Bool
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DLLEXPORT_API extern __declspec(dllexport)
|
||||
#define DLL_VOID void __stdcall
|
||||
#define DLL_INT int __stdcall
|
||||
#else
|
||||
#define DLLEXPORT_API
|
||||
#define DLL_VOID void
|
||||
#define DLL_INT int
|
||||
#endif
|
||||
|
||||
typedef struct _List List;
|
||||
|
||||
struct _List
|
||||
{
|
||||
void* data;
|
||||
List *next;
|
||||
List *prev;
|
||||
};
|
||||
|
||||
typedef struct _Queue Queue;
|
||||
|
||||
struct _Queue
|
||||
{
|
||||
List *head;
|
||||
List *tail;
|
||||
unsigned int length;
|
||||
};
|
||||
|
||||
typedef struct _AsyncQueue AsyncQueue;
|
||||
|
||||
#ifdef _WIN32
|
||||
//mutex and cond are different in WIN and Linux.
|
||||
struct _AsyncQueue
|
||||
{
|
||||
SRWLOCK mutex;
|
||||
CONDITION_VARIABLE cond;
|
||||
Queue queue;
|
||||
unsigned int waiting_threads;
|
||||
int ref_count;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
struct _AsyncQueue
|
||||
{
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
Queue queue;
|
||||
unsigned int waiting_threads;
|
||||
int ref_count;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
//add a new point to the List
|
||||
//向队列中增加一个指针
|
||||
DLLEXPORT_API List* list_append(List *list, void* data);
|
||||
|
||||
// Initialization of the queue
|
||||
// 队列初始化函数
|
||||
DLLEXPORT_API DLL_VOID queue_init(Queue *queue);
|
||||
|
||||
// Push a data point to the queue head,and increase the leagth for 1.
|
||||
// 将一个数据指针推送到队列头,并将队列长度增加1。
|
||||
DLLEXPORT_API DLL_VOID queue_push_head(Queue *queue, void *data);
|
||||
|
||||
// Pop a data From the tail of the queue and return the point, If there isn't a data, Then return NUll.
|
||||
// 从队列尾推出一个数据,并返回这个数据指针。如果没有数据,则返回NULL。
|
||||
DLLEXPORT_API void* queue_pop_tail(Queue *queue);
|
||||
|
||||
// Release all the queue, but not the data point.
|
||||
// If the data point is generate by malloc, it should free first.
|
||||
// 释放队列,但不是队列中data指向的数据,如果队列的data是开辟的空间,应先释放。
|
||||
DLLEXPORT_API DLL_VOID queue_clear(Queue *queue);
|
||||
|
||||
// Check If there is data or not in the queue.
|
||||
// 查看队列是否有数据
|
||||
DLLEXPORT_API List* queue_peek_tail_link(Queue *queue);
|
||||
|
||||
// Creat a AsyncQueue.
|
||||
// If successed, it return a point to a AsyncQueue.
|
||||
// Otherwise, it return a NULL point.
|
||||
// 创建一个异步队列。如果成功,返回队列的指针,否则,返回NULL。
|
||||
DLLEXPORT_API AsyncQueue* async_queue_new();
|
||||
|
||||
// Push a point data to the AsyncQueue head. After this, the queue length will increase one.
|
||||
// input AsyncQueue point; data point.
|
||||
// 将数据指针推送到异步队形头,然后队列长度增加1。 输入参数: 队列指针,数据指针。
|
||||
DLLEXPORT_API DLL_VOID async_queue_push(AsyncQueue *queue, void *data);
|
||||
|
||||
// Pop a point of the data from AsyncQueue tail, After this, the queue length will decrease one and return a point.
|
||||
// It will waiting point until there is one. It is a blocking function.
|
||||
// 将一个数据从队列中弹出,然后队列长度减少1,返回数据的指针。 这个函数会一直等到有数据,这是一个阻塞函数。
|
||||
DLLEXPORT_API void* async_queue_pop(AsyncQueue *queue);
|
||||
|
||||
// Try Pop a point of the data from AsyncQueue tail, If successed, the queue length will decrease one and return a point.
|
||||
// If not successed, it return NULL. This function return immediately.
|
||||
// 尝试将一数据从队列中弹出,如果成功,队列长度减少1,返回数据指针。 如果无数据,就返回NULL,这个函数是立即返回。
|
||||
DLLEXPORT_API void* async_queue_try_pop(AsyncQueue *queue);
|
||||
|
||||
// Pop a point of the data from AsyncQueue tail until the timeout.
|
||||
// If during the timeout, there is data, the queue length will decrease one and return a point.
|
||||
// If during the timeout, there is no data, it return NULL.
|
||||
// the unit of timeout is us.
|
||||
// 在等待的时间内尝试将一数据从队列中弹出,如果成功,队列长度减少1,返回数据指针。 如果无数据,就返回NULL。
|
||||
// 这个函数的返回时间是小于等于等待时间的。
|
||||
DLLEXPORT_API void* async_queue_timeout_pop(AsyncQueue *queue,
|
||||
long long timeout);
|
||||
|
||||
// return the length of AsyncQueue
|
||||
// 返回异步队列的长度
|
||||
DLLEXPORT_API DLL_INT async_queue_length(AsyncQueue *queue);
|
||||
|
||||
// release the AsyncQueue
|
||||
// 释放异步队列资源
|
||||
DLLEXPORT_API DLL_VOID async_queue_destroy(AsyncQueue *queue);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
308
include/dkam_base_type.h
Normal file
308
include/dkam_base_type.h
Normal file
@@ -0,0 +1,308 @@
|
||||
/********************************************************************************************
|
||||
Copyright : XianZhisensorTechnologiesCo.,Ltd
|
||||
File Name : discovery.h
|
||||
Description: Privide base type of gige camera
|
||||
Author : Yaming Wang
|
||||
Version : 1.0
|
||||
Data : 2019-11-18
|
||||
History :
|
||||
*********************************************************************************************/
|
||||
#ifndef DKAM_BASE_TYPE_H
|
||||
#define DKAM_BASE_TYPE_H
|
||||
|
||||
#define IP_HEADER_LEN 20
|
||||
#define UDP_HEADER_LEN 8
|
||||
#define IMAGE_PACKET_HEADER_LEN 8
|
||||
#define BLOCK_HEAD_LEN 44
|
||||
|
||||
|
||||
#define GVCP_PORT 3956
|
||||
|
||||
#define SORT_BY_IP 0
|
||||
#define SORT_BY_SERIAL_NUMBER 1
|
||||
|
||||
//发送命令宏定义
|
||||
#define PACK_START 0x42
|
||||
#define DISCOVERY_CMD 0x0002
|
||||
//#define DISCOVERY_ACK 0x0003
|
||||
#define FORCEIP_CMD 0x0004
|
||||
//#define FORCEIP_ACK 0x0005
|
||||
#define READREG_CMD 0x0080
|
||||
//#define READREG_ACK 0x0081
|
||||
#define WRITEREG_CMD 0x0082
|
||||
//#define WRITEREG_ACK 0x0083
|
||||
#define READMEM_CMD 0x0084
|
||||
//#define READMEM_ACK 0x0085
|
||||
#define WRITEMEM_CMD 0x0086
|
||||
//#define WRITEMEM_ACK 0x0087
|
||||
#define PACKETRESEND_CMD 0x0040
|
||||
|
||||
|
||||
//GIGE version协议标准寄存器
|
||||
#define Control_Channel_Privilage_Reg 0x00000A00
|
||||
#define GVCP_Capability_Reg 0x00000934
|
||||
#define Number_of_Message_Channels_Reg 0x00000900
|
||||
#define Number_of_Stream_Channels_Reg 0x00000904
|
||||
#define First_Url_Reg 0x00000200
|
||||
#define Second_Url_Reg 0x00000400
|
||||
#define Heartbeat_Timeout_Reg 0x00000938
|
||||
|
||||
#define Source_Port_Reg 0x00000D1C
|
||||
|
||||
#define Stream_Channel_0_Port_Reg 0x00000D00
|
||||
#define Stream_Channel_0_Destination_Address_Reg 0x00000D18
|
||||
|
||||
//#define Stream_Channel_1_Port_Reg 0x00000D40
|
||||
//#define Stream_Channel_1_Destination_Address_Reg 0x00000D58
|
||||
//
|
||||
//#define Stream_Channel_2_Port_Reg 0x00000D80
|
||||
//#define Stream_Channel_2_Destination_Address_Reg 0x00000D98
|
||||
|
||||
#define Stream_Channel_Packet_Size_Reg 0x00000D04
|
||||
|
||||
//自定义寄存器
|
||||
|
||||
|
||||
#define Model_Adder 0x00000014
|
||||
#define IP_Adder 0x0000064C
|
||||
#define Mask_Adder 0x0000065C
|
||||
#define Gate_Adder 0x0000066C
|
||||
|
||||
|
||||
typedef struct RoiPoint {
|
||||
unsigned int size_x;
|
||||
unsigned int size_y;
|
||||
unsigned int offset_x;
|
||||
unsigned int offset_y;
|
||||
}RoiPoint;
|
||||
|
||||
#define RECIEVE_TIME_STATISTICS_LENGTH 1000 //统计直方图划分的尺寸,默认1000个
|
||||
typedef struct {
|
||||
int offset; //初始偏量
|
||||
unsigned int bin_steps; //步长
|
||||
unsigned int n_bins; //总步数
|
||||
int max; //最大值
|
||||
int min; //最小值
|
||||
long long count; //总数量
|
||||
long long add_more; //大于统计范围的数量
|
||||
long long add_less; //小于统计范围的数量
|
||||
long long bins[RECIEVE_TIME_STATISTICS_LENGTH];
|
||||
}StatisticsData;
|
||||
//C#
|
||||
typedef struct {
|
||||
int offset; //初始偏量
|
||||
unsigned int bin_steps; //步长
|
||||
unsigned int n_bins; //总步数
|
||||
int max; //最大值
|
||||
int min; //最小值
|
||||
long long count; //总数量
|
||||
long long add_more; //大于统计范围的数量
|
||||
long long add_less; //小于统计范围的数量
|
||||
}StatisticsDataCSharp;
|
||||
|
||||
//照片信息结构体
|
||||
typedef struct PhotoInfo {
|
||||
char* pixel;
|
||||
unsigned int pixel_length;
|
||||
unsigned int pixel_format;
|
||||
unsigned int pixel_width;
|
||||
unsigned int pixel_height;
|
||||
unsigned int cloud_unit;
|
||||
unsigned int payload_size;
|
||||
unsigned long int timestamp_high;
|
||||
unsigned long int timestamp_low;
|
||||
RoiPoint roi;
|
||||
unsigned short block_id;
|
||||
unsigned short stream_channel_index_;
|
||||
unsigned int gvsp_payload_size;
|
||||
int buffer_status; // 当前包传输状态
|
||||
}PhotoInfo;
|
||||
|
||||
//照片信息结构体C#专用
|
||||
typedef struct PhotoInfoCSharp {
|
||||
unsigned int pixel_length;
|
||||
unsigned int pixel_format;
|
||||
unsigned int pixel_width;
|
||||
unsigned int pixel_height;
|
||||
unsigned int cloud_unit;
|
||||
unsigned int payload_size;
|
||||
unsigned long int timestamp_high;
|
||||
unsigned long int timestamp_low;
|
||||
RoiPoint roi;
|
||||
unsigned short block_id;
|
||||
unsigned short stream_channel_index_;
|
||||
unsigned int gvsp_payload_size;
|
||||
int buffer_status; // 当前包传输状态
|
||||
}PhotoInfoCSharp;
|
||||
|
||||
//暂存区数据结构体
|
||||
typedef struct RecvDataBuff {
|
||||
unsigned short status;
|
||||
char head_packet_flag;
|
||||
char* data;
|
||||
char block_head[BLOCK_HEAD_LEN];
|
||||
struct RecvDataBuff* next;
|
||||
}RecvDataBuff;
|
||||
|
||||
//数据缓冲池结构体
|
||||
typedef struct RecvDataTemp {
|
||||
char head_packet_flag;
|
||||
char resend_check_point;
|
||||
char out_of_time_check;
|
||||
unsigned short block_id;
|
||||
unsigned int recv_packet_num;
|
||||
unsigned int all_data_size;
|
||||
unsigned int all_packet_num;
|
||||
char* recv_packet_id;
|
||||
char* data;
|
||||
char *block_head;
|
||||
struct RecvDataTemp* next;
|
||||
}RecvDataTemp;
|
||||
|
||||
//相机信息结构体
|
||||
typedef struct DiscoveryInfo {
|
||||
unsigned int camera_ip;
|
||||
unsigned int camera_mask;
|
||||
unsigned int camera_gateway;
|
||||
unsigned int camera_mac_low;
|
||||
unsigned short camera_mac_high;
|
||||
char device_vendor_name[32];
|
||||
char device_model_name[32];
|
||||
char device_version[32];
|
||||
char device_manufacturer_info[48];
|
||||
char device_serial_number[16];
|
||||
char device_user_id[16];
|
||||
unsigned int computer_ip;
|
||||
unsigned int computer_mask;
|
||||
unsigned int computer_gateway;
|
||||
int mtu;
|
||||
char computer_adapter[256];
|
||||
}DiscoveryInfo;
|
||||
|
||||
typedef struct PacketInfo {
|
||||
unsigned short in_status;
|
||||
unsigned short in_block_id;
|
||||
unsigned short in_packet_id;
|
||||
unsigned char packet_format;
|
||||
int data_packet_len;
|
||||
}PacketInfo;
|
||||
|
||||
//相机参数
|
||||
typedef struct CameraParameter {
|
||||
float Kc[5];
|
||||
float K[9];
|
||||
float R[9];
|
||||
float T[3];
|
||||
}CameraParameter;
|
||||
|
||||
//连接相机信息
|
||||
typedef struct InstanceDevice {
|
||||
unsigned int camera_ip;
|
||||
unsigned int camera_mask;
|
||||
unsigned int computer_ip;
|
||||
unsigned int computer_mask;
|
||||
int computer_mtu;
|
||||
int recv_buffer_num;
|
||||
char computer_adapter[256];
|
||||
}InstanceDevice;
|
||||
|
||||
//命令包
|
||||
//discover_cmd
|
||||
typedef struct DiscoverCmdPack {
|
||||
unsigned char start;
|
||||
unsigned char flag;
|
||||
unsigned short command;
|
||||
unsigned short length;
|
||||
unsigned short req_id;
|
||||
}DiscoverCmdPack;
|
||||
|
||||
//force_ip_cmd
|
||||
typedef struct ForceIpCmdPack {
|
||||
unsigned char start;
|
||||
unsigned char flag;
|
||||
unsigned short command;
|
||||
unsigned short length;
|
||||
unsigned short req_id;
|
||||
unsigned short reserved;
|
||||
unsigned short mac_addr_high;
|
||||
unsigned int mac_addr_low;
|
||||
unsigned int reserved1[3];
|
||||
unsigned int ip;
|
||||
unsigned int reserved2[3];
|
||||
unsigned int mask;
|
||||
unsigned int reserved3[3];
|
||||
unsigned int gateway;
|
||||
}ForceIpCmdPack;
|
||||
//force_ip_reboot
|
||||
typedef struct ForceIpRebootCmdPack {
|
||||
unsigned char start;
|
||||
unsigned char flag;
|
||||
unsigned short command;
|
||||
unsigned short length;
|
||||
unsigned short req_id;
|
||||
unsigned int model_addr;
|
||||
unsigned int model;
|
||||
unsigned int ip_addr;
|
||||
unsigned int ip;
|
||||
unsigned int mask_addr;
|
||||
unsigned int mask;
|
||||
unsigned int gateway_addr;
|
||||
unsigned int gateway;
|
||||
unsigned int restart_addr;
|
||||
unsigned int restart;
|
||||
}ForceIpRebootCmdPack;
|
||||
//write_register_cmd
|
||||
typedef struct WriteRegCmdPack {
|
||||
unsigned char start;
|
||||
unsigned char flag;
|
||||
unsigned short command;
|
||||
unsigned short length;
|
||||
unsigned short req_id;
|
||||
unsigned int register_addr;
|
||||
unsigned int data;
|
||||
}WriteRegCmdPack;
|
||||
//read_register_cmd
|
||||
typedef struct ReadRegCmdPack {
|
||||
unsigned char start;
|
||||
unsigned char flag;
|
||||
unsigned short command;
|
||||
unsigned short length;
|
||||
unsigned short req_id;
|
||||
unsigned int register_addr;
|
||||
}ReadRegCmdPack;
|
||||
|
||||
//read_mem_cmd
|
||||
typedef struct ReadMemCmdPack {
|
||||
unsigned char start;
|
||||
unsigned char flag;
|
||||
unsigned short command;
|
||||
unsigned short length;
|
||||
unsigned short req_id;
|
||||
unsigned int address;
|
||||
unsigned short reserved;
|
||||
unsigned short count;
|
||||
}ReadMemCmdPack;
|
||||
//write_mem_cmd
|
||||
typedef struct WriteMemCmdPack {
|
||||
unsigned char start;
|
||||
unsigned char flag;
|
||||
unsigned short command;
|
||||
unsigned short length;
|
||||
unsigned short req_id;
|
||||
unsigned int address;
|
||||
char data[536];
|
||||
}WriteMemCmdPack;
|
||||
//resend_cmd_pack
|
||||
typedef struct PacketResendCmdPack {
|
||||
unsigned char start;
|
||||
unsigned char flag;
|
||||
unsigned short command;
|
||||
unsigned short length;
|
||||
unsigned short req_id;
|
||||
unsigned short stream_channel_index;
|
||||
unsigned short block_id;
|
||||
unsigned int first_packet_id;
|
||||
unsigned int last_packet_id;
|
||||
}PacketResendCmdPack;
|
||||
|
||||
#endif //!DKAM_BASE_TYPE_H
|
||||
130
include/dkam_camera_error.h
Normal file
130
include/dkam_camera_error.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/********************************************************************************
|
||||
Copyright : XianZhisensorTechnologiesCo.,Ltd
|
||||
File Name :camera_error
|
||||
Description: Privide information of error
|
||||
Author : Yaming Wang
|
||||
Version : 1.0
|
||||
Data : 2019-11-
|
||||
History :
|
||||
*********************************************************************************/
|
||||
|
||||
#ifndef DKAM_CAMERA_ERROR_H_
|
||||
#define DKAM_CAMERA_ERROR_H_
|
||||
|
||||
//局域网内未发现相机
|
||||
|
||||
#define SUCCESS 0
|
||||
|
||||
//#define MALLOC_ERROR -1
|
||||
#define INVALID_PARAMETER -2
|
||||
#define NETWORK_INTERFACE_CONTROLLER_ERROR -3 //网卡错误
|
||||
#define FORCE_IP_TIMEOUT -4
|
||||
|
||||
#define NO_CAMERA -5
|
||||
#define INIT_SOCKET_ERROR -6
|
||||
#define SOCKET_BIND_ERROR -7
|
||||
#define TEST_PACKET_SEND_ERROR -8
|
||||
//#define GET_XML_URL_ERROR -9
|
||||
#define XML_DATA_ERROR -10
|
||||
|
||||
#define CAMERA_DISCONNECT -11
|
||||
//#define CREATE_LOG_ERROR -12
|
||||
#define GET_MTU_ERROR -13
|
||||
//#define GET_PACK_SIZE_ERROR -14
|
||||
#define USER_CONFIG_FILE_ERROR -15
|
||||
//#define SET_CAMERA_ATTRIBUTION_ERROR -16
|
||||
#define CAMERA_ATTRIBUTION_ERROR -17
|
||||
//#define TRIGGER_ERROR -18
|
||||
#define CREATE_THREAD_ERROR -19
|
||||
//#define STREAM_ON_ERROR -20
|
||||
#define NO_REGISTER -21
|
||||
#define UNIMPLEMENTED_PIXEL_FORMAT -22
|
||||
//#define ACQUISITION_START_ERROR -23
|
||||
//#define ACQUISITION_STOP_ERROR -24
|
||||
//#define SET_ROI_ERROR -25
|
||||
//#define STREAM_OFF_ERROR -26
|
||||
//#define DISCONNECT_ERROR -27
|
||||
//#define GET_NODE_MAX_VALUE_ERROR -28
|
||||
//#define GET_NODE_MIN_VALUE_ERROR -29
|
||||
//#define SET_HEART_BEAT_TIMEOUT_ERROR -30
|
||||
//#define GET_HEART_BEAT_TIMEOUT_ERROR -31
|
||||
|
||||
//gvsp
|
||||
//#define SELECT_TIMEOUT -32
|
||||
//#define INVALID_CHANNEL_INDEX -33
|
||||
#define CAPTURE_TIMEOUT -34
|
||||
#define CAPTURE_ERROR -35
|
||||
|
||||
#define INET_PTON_ERROR -36
|
||||
#define WRITE_REG_TIMEOUT -37
|
||||
#define READ_REG_TIMEOUT -38
|
||||
#define WRITE_MEM_TIMEOUT -39
|
||||
#define READ_MEM_TIMEOUT -40
|
||||
//save_data
|
||||
#define SAVE_ERROR -41
|
||||
#define OPEN_FILE_ERROR -42
|
||||
//#define SAVE_XML_ERROR -43
|
||||
#define FTP_OPEN_ERROR -44
|
||||
#define FTP_CONNECT_ERROR -45
|
||||
#define FTP_PUT_ERROR -46
|
||||
#define FTP_GET_ERROR -47
|
||||
//#define CAMERA_REBOOT_ERROR -48
|
||||
|
||||
#define DIFFERENT_NETWORK_SEGMENT -49
|
||||
#define NULL_PTR -50
|
||||
//#define GET_NODE_INC_VALUE_ERROR -51
|
||||
|
||||
|
||||
//#define WRITE_REG_ERROR -52 //修改完未用
|
||||
//#define READ_REG_ERROR -53 //修改完未用
|
||||
//#define WRITE_MEM_ERROR -54 //修改完未用
|
||||
//#define READ_MEM_ERROR -55 //修改完未用
|
||||
#define RECEIVE_ERROR -56
|
||||
//#define GET_CAM_INTERN_PARAM_ERROR -57
|
||||
//#define GET_CAM_EXTERN_PARAM_ERROR -58
|
||||
|
||||
//#define FUSION_ERROR -59 //修改完未用
|
||||
#define GET_CCP_STATUS_ERROR -60
|
||||
#define LAST_TRIGGER_NOT_END -61
|
||||
#define CONNECTED_BY_OTHERS -62
|
||||
#define REGISTER_ACCESS_ERROR -63
|
||||
|
||||
#define CREATE_DISCOVER_OBJ_ERROR -97
|
||||
#define CREATE_STREAM_OBJ_ERROR -98
|
||||
#define CREATE_CAMERA_OBJ_ERROR -99
|
||||
|
||||
#define GEV_STATUS_SUCCESS 0x0000 //命令执行成功
|
||||
#define GEV_STATUS_PACKET_RESEND 0x0100 //重发包
|
||||
#define GEV_STATUS_NOT_IMPLEMENTED 0x8001 //设备不支持该命令
|
||||
#define GEV_STATUS_INVALID_PARAMETER 0x8002 //参数无效
|
||||
#define GEV_STATUS_INVALID_ADDRESS 0x8003 //试图访问不存在的地址空间位置
|
||||
#define GEV_STATUS_WRITE_PROTECT 0x8004 //寄存器地址无法写入
|
||||
#define GEV_STATUS_BAD_ALIGNMENT 0x8005 //地址偏移量或数据大小对齐错误
|
||||
#define GEV_STATUS_ACCESS_DENIED 0x8006 //试图访问永久/暂时无法访问的地址
|
||||
#define GEV_STATUS_BUSY 0x8007 //请求繁忙
|
||||
#define GEV_STATUS_LOCAL_PROBLEM 0x8008
|
||||
#define GEV_STATUS_MSG_MISMATCH 0x8009
|
||||
#define GEV_STATUS_INVALID_PROTOCOL 0x800A
|
||||
#define GEV_STATUS_NO_MSG 0x800B
|
||||
#define GEV_STATUS_PACKET_UNAVAILABLE 0x800C //请求的数据包不可用
|
||||
#define GEV_STATUS_DATA_OVERRUN 0x800D //GVSP发送器内部存储器溢出
|
||||
#define GEV_STATUS_INVALID_HEADER 0x800E
|
||||
#define GEV_STATUS_WRONG_CONFIG 0x800F
|
||||
#define GEV_STATUS_PACKET_NOT_YET_AVAILABLE 0x8010 //尚未获取请求的数据包
|
||||
#define GEV_STATUS_PACKET_AND_PREV_REMOVED_FROM_MEMORY 0x8011 //请求的数据包和所有先前的数据包不再可用,并已从GVSP发送器存储器中丢失
|
||||
#define GEV_STATUS_PACKET_REMOVED_FROM_MEMORY 0x8012 //请求的数据包不可用,且从GVSP发送器存储器中丢失
|
||||
#define GEV_STATUS_NO_REF_TIME 0x8013 //设备未与主时钟同步以用作时间参考
|
||||
#define GEV_STATUS_PACKET_TEMPORARILY_UNAVAILABLE 0x8014 //由于临时宽带问题,此时无法重新发送数据包,应在将来再次请求
|
||||
#define GEV_STATUS_OVERFLOW 0x8015 //设备队列或数据包数据已溢出
|
||||
#define GEV_STATUS_ACTION_LATE 0x8016 //在已经过去的时间请求里请求的预定动作命令
|
||||
#define GEV_STATUS_LEADER_TRAILER_OVERFLOW 0x8017 //数据头包或数据尾包的数据包大小不足以放入用于传输该块的所有信息
|
||||
#define GEV_STATUS_SLERROR 0xC001 //光机异常
|
||||
#define GEV_STATUS_CMOSERROR 0xC002 //CMOS异常
|
||||
#define GEV_STATUS_GPUERROR 0xC003 //GPU异常
|
||||
#define GEV_STATUS_OTHERERROR 0xC004 //其他异常
|
||||
#define GEV_STATUS_UPDATEERROR 0xC005
|
||||
#define GEV_STATUS_ERROR 0xCFFF //一般错误
|
||||
|
||||
|
||||
#endif //!DKAM_CAMERA_ERROR_H_
|
||||
|
||||
32
include/dkam_common_socket.h
Normal file
32
include/dkam_common_socket.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/**************************************************************************************************************
|
||||
Copyright : XianZhisensorTechnologiesCo.,Ltd
|
||||
File Name : common_socket.h
|
||||
Description: Privide Definition of class
|
||||
Author : Yaming Wang
|
||||
Version : 1.0
|
||||
Data : 2019-11-3
|
||||
History :
|
||||
***************************************************************************************************************/
|
||||
#ifndef DKAM_COMMON_SOCKET_H
|
||||
#define DKAM_COMMON_SOCKET_H
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
|
||||
|
||||
class CommonSocket {
|
||||
public:
|
||||
CommonSocket();
|
||||
~CommonSocket();
|
||||
int InitSocket();
|
||||
int Bind(int socket_fd, unsigned int ip, unsigned short port);
|
||||
int Send(int socket_fd, unsigned int ip, unsigned short port, const char* buffer, unsigned int buffer_len);
|
||||
int Receive(int socket_fd, char* buffer, int buffer_len);
|
||||
int Select(int socket_fd, fd_set *rd_fds, fd_set *wd_fds);
|
||||
};
|
||||
|
||||
|
||||
#endif //!DKAM_COMMON_SOCKET_H
|
||||
54
include/dkam_discovery.h
Normal file
54
include/dkam_discovery.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/********************************************************************************************
|
||||
Copyright : XianZhisensorTechnologiesCo.,Ltd
|
||||
File Name : discovery.h
|
||||
Description: Privide class of discover
|
||||
Author : Yaming Wang
|
||||
Version : 1.0
|
||||
Data : 2019-11-18
|
||||
History :
|
||||
*********************************************************************************************/
|
||||
#ifndef DKAM_DISCOVERY_H
|
||||
#define DKAM_DISCOVERY_H
|
||||
#include "dkam_log.h"
|
||||
#include "dkam_base_type.h"
|
||||
#include "dkam_common_socket.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
class Discovery :private CommonSocket{
|
||||
public:
|
||||
Discovery();
|
||||
~Discovery();
|
||||
//设置发现设备时log日志的等级开关,决定是否开启某一个等级的日志打印,默认关闭(0:关闭 1:开启)
|
||||
void SetLogLevelSwitch(int error, int debug, int warnning, int info);
|
||||
//发现相机
|
||||
int DiscoverCamera(std::vector<DiscoveryInfo>* discovery_info);
|
||||
//对发现的相机排序 0 IP 1 序列号
|
||||
int CameraSort(std::vector <DiscoveryInfo>* discovery_info, int sort_mode);
|
||||
//设置相机ip
|
||||
int ForceIp(DiscoveryInfo discovery_info, char* ip, char* mask, char* gateway);
|
||||
//两点分十进制ip转化为int型
|
||||
unsigned int ConvertIpStringToInt(char* str_ip);
|
||||
//将int型ip转换为点分十进制形式
|
||||
char *ConvertIpIntToString(unsigned int ip);
|
||||
//判断相机的IP和PC的IP是否在同一网段
|
||||
bool WhetherIsSameSegment(DiscoveryInfo discovery_info);
|
||||
|
||||
private:
|
||||
//win32平台发现相机
|
||||
int DiscoverCameraWin32(std::vector<DiscoveryInfo>** discovery_info);
|
||||
//linux平台发现相机
|
||||
int DiscoverCameraLinux(std::vector<DiscoveryInfo>** discovery_info);
|
||||
|
||||
private:
|
||||
int camera_num_;
|
||||
unsigned short req_id_;
|
||||
char *camera_ip_;
|
||||
cameralog logq;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //!DKAM_DISCOVERY_H
|
||||
|
||||
50
include/dkam_ftpserver.h
Normal file
50
include/dkam_ftpserver.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <WinSock2.h>
|
||||
#include <wininet.h>
|
||||
//链接wininet.lib库
|
||||
#pragma comment(lib,"wininet.lib")
|
||||
#else
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif // _WIN32
|
||||
|
||||
class FtpServer
|
||||
{
|
||||
public:
|
||||
FtpServer();
|
||||
~FtpServer();
|
||||
// ftp 文件上传
|
||||
int FtpUpload(const char* ip, const char* localPathName, const char* uploadPath);
|
||||
int FtpDownload(const char* ip, const char* LocalPath, const char* LocalName, const char* downPath);
|
||||
int FtpGetFileList(const char* ip, const char* filePath, std::vector<std::string>* fileNames);
|
||||
private:
|
||||
int FtpUploadWin(const char* ip, const char* localPathName, const char* uploadPathName);
|
||||
int FtpDownloadWin(const char* ip, const char* LocalPathName, const char* downPathName);
|
||||
int FtpGetFileListWin(const char* ip, const char* filePath, std::vector<std::string>* fileNames);
|
||||
|
||||
int FtpUploadLin(const char* ip, const char* localPathName, const char* uploadPathName);
|
||||
int FtpDownloadLin(const char* ip, const char* LocalPathName, const char* downPathName);
|
||||
int FtpGetFileListLin(const char* ip, const char* filePath, std::vector<std::string>* fileNames);
|
||||
|
||||
|
||||
private:
|
||||
int ftpServerProt_m_;
|
||||
char* ftpUserName_m_;
|
||||
char* ftpUserPwd_m_;
|
||||
#ifdef _WIN32
|
||||
char* szAppname_m_;
|
||||
char* szUsername_m_;
|
||||
char* szPassword_m_;
|
||||
#else
|
||||
#endif // _WIN32
|
||||
};
|
||||
|
||||
385
include/dkam_gige_camera.h
Normal file
385
include/dkam_gige_camera.h
Normal file
@@ -0,0 +1,385 @@
|
||||
/*************************************************************************************
|
||||
Copyright : XianZhisensorTechnologiesCo.,Ltd
|
||||
File Name : gige_camera.h
|
||||
Description: Privide Definition of class
|
||||
Author : Yaming Wang
|
||||
Version : 1.0
|
||||
Data : 2019-11-3
|
||||
History :
|
||||
*************************************************************************************/
|
||||
#ifndef DKAM_GIGE_CAMERA_H
|
||||
#define DKAM_GIGE_CAMERA_H
|
||||
|
||||
#include "dkam_log.h"
|
||||
#include "dkam_base_type.h"
|
||||
#include "dkam_common_socket.h"
|
||||
#include "dkam_ftpserver.h"
|
||||
#include <iostream>
|
||||
#include <stdbool.h>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include<windows.h>
|
||||
#include <WS2tcpip.h>
|
||||
#else
|
||||
#include <semaphore.h>
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
int socket_id;
|
||||
unsigned int payload_size;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
RoiPoint roi;
|
||||
unsigned int pixel_length;
|
||||
unsigned int pixel_format;
|
||||
unsigned int pack_num;
|
||||
unsigned int cloud_unit;
|
||||
}DataStreamPrivateInfo;
|
||||
|
||||
|
||||
typedef struct {
|
||||
RecvDataBuff recv_data_buff[3];//暂存区buffer
|
||||
RecvDataBuff *read_position[3]; //指向暂存区buffer的读指针
|
||||
RecvDataBuff *write_position[3]; // 指向暂存区buffer的写指针
|
||||
}DataStreamBufferInfo;
|
||||
|
||||
class GigeStream;
|
||||
extern char* sdk_version;
|
||||
|
||||
//相机控制,接收数据类
|
||||
class GigeCamera :private CommonSocket{
|
||||
public:
|
||||
GigeCamera();
|
||||
~GigeCamera();
|
||||
//获取相机的CCP状态(返回0为可连接)
|
||||
int GetCameraCCPStatus(DiscoveryInfo* discovery_info, int *data);
|
||||
//连接相机
|
||||
int CameraConnect(DiscoveryInfo* discovery_info);
|
||||
//建立通道和com之间对应关系
|
||||
int ChannalCorrespondComs();
|
||||
//获取相机xml所有节点名称
|
||||
int GetCameraXMLNodeNames(std::vector<std::string>* node_names);
|
||||
//验证ip是否合法
|
||||
bool IsIPAddressValid(unsigned int ip_int, unsigned int camera_mask_int);
|
||||
//获取节点最大值
|
||||
int GetNodeMaxValue(const char* key);
|
||||
//获取节点最小值
|
||||
int GetNodeMinValue(const char* key);
|
||||
//获取int节点增量
|
||||
int GetNodeIncValue(const char* key);
|
||||
//获取相机内参
|
||||
int GetCamInternelParameter(int camera_cnt, float *Kc, float *K);
|
||||
//获取相机外参
|
||||
int GetCamExternelParameter(int camera_cnt, float *R, float *T);
|
||||
//图像膨胀
|
||||
void PixelSwell(int *roi_output, PhotoInfo &target_data);
|
||||
//图像腐蚀
|
||||
void PixelCorrosion(int *roi_output, PhotoInfo &target_data);
|
||||
//ROI映射区域坐标
|
||||
void ROIMappingCoordinate(int *roi_output, PhotoInfo &target_data, RoiPoint &point_output);
|
||||
//ROI检索映射
|
||||
void ROIPixelMapping(PhotoInfo &point_data, PhotoInfo &source_data, PhotoInfo &target_data, RoiPoint &roi_input, int *ROI_output);
|
||||
//写寄存器 返回写寄存器是否成功的状态码
|
||||
int WriteRegister(unsigned int register_addr, int data);
|
||||
//保存用户配置文件
|
||||
int SaveUserConfig(char* fliename);
|
||||
//加载用户配置文件
|
||||
int LoadUserConfig(char* fliename);
|
||||
//获取节点类型
|
||||
int GetNodeType(const char* key);
|
||||
//获取节点访问模式
|
||||
int GetNodeAccessMode(const char* key);
|
||||
//设置Int类型节点值
|
||||
int SetIntNodeValue(const char* key, unsigned int value);
|
||||
//设置Bool类型节点值
|
||||
int SetBoolNodeValue(const char* key, int value);
|
||||
//设置Command类型节点值
|
||||
int SetCommandNodeValue(const char* key);
|
||||
//设置Float类型节点值
|
||||
int SetFloatNodeValue(const char* key, float value);
|
||||
//设置String类型节点值
|
||||
int SetStringNodeValue(const char* key, char* value);
|
||||
//设置Enumeration类型节点值
|
||||
int SetEnumNodeValue(const char* key, int value);
|
||||
//获取Int类型节点值
|
||||
int GetIntNodeValue(const char* key, int* value);
|
||||
//获取相机节点value
|
||||
int GetRegisterAddr(const char* key);
|
||||
//读string类型的寄存器
|
||||
int ReadStringRegister(const char* key, char* reg_str);
|
||||
//写string类型的寄存器
|
||||
int WriteStringRegister(const char* key, unsigned short datasize, char* reg_str);
|
||||
//获取Bool类型节点值
|
||||
int GetBoolNodeValue(const char* key, int* value);
|
||||
//获取Command类型节点值
|
||||
int GetCommandNodeValue(const char* key, char* value);
|
||||
//获取Float类型节点值
|
||||
int GetFloatNodeValue(const char* key, float* value);
|
||||
//获取String类型节点值
|
||||
int GetStringNodeValue(const char* key, char* value);
|
||||
//获取Enumeration类型节点值
|
||||
int GetEnumNodeValue(const char* key, int* value);
|
||||
//读寄存器 返回读寄存器是否成功的状态码 register_addr:寄存器地址 data:读取的寄存器的值
|
||||
int ReadRegister(unsigned int register_addr, int *data);
|
||||
//设置相机种类 (0:红外;1:RGB)
|
||||
int SetCameraType(int camera_cnt);
|
||||
//获取相机种类 (0:红外;1:RGB)
|
||||
int GetCameraType();
|
||||
//获取相机的宽
|
||||
int GetCameraWidth(int* width, int camera_cnt);
|
||||
//设置相机的宽
|
||||
int SetCameraWidth(int width, int camera_cnt);
|
||||
//获取相机的高
|
||||
int GetCameraHeight(int* height, int camera_cnt);
|
||||
//设置相机的高
|
||||
int SetCameraHeight(int height, int camera_cnt);
|
||||
////设置超时时间
|
||||
int SetHeartBeatTimeout(int value);
|
||||
//获取超时时间
|
||||
int GetHeartBeatTimeout(void);
|
||||
//设置相机曝光模式(1手动曝光,0自动曝光 camera_cnt:0是红外, 1是RGB)
|
||||
int SetAutoExposure(int status, int camera_cnt);
|
||||
//获取相机曝光模式 ( camera_cnt:0是红外, 1是RGB)
|
||||
int GetAutoExposure(int camera_cnt);
|
||||
//设置RGB摄像头自动曝光增益的级别(>=1 仅支持RGB摄像头) (camera_cnt:相机的摄像头0:红外摄像头 1:RGB摄像头 level:曝光增益等级)
|
||||
int SetCamExposureGainLevel(int camera_cnt, int level);
|
||||
//获取RGB摄像头自动曝光增益的级别,仅支持RGB摄像头(camera_cnt:相机的摄像头0:红外摄像头 1:RGB摄像头)
|
||||
int GetCamExposureGainLevel(int camera_cnt);
|
||||
//设置相机曝光类型int status > 0 多曝光 不能是0
|
||||
int SetMutipleExposure(int status);
|
||||
//获取相机曝光类型
|
||||
int GetMutipleExposure(void);
|
||||
//设置曝光时间,utimes:曝光时间: 红外镜头范围1000 - 100000um, RGB镜头范围1000 - 56000um, 默认16600,camera_cnt:0是红外, 1是RGB
|
||||
int SetExposureTime(int utime, int camera_cnt);
|
||||
//获取相机曝光次数 0是红外, 1是RGB
|
||||
int GetExposureTime(int camera_cnt);
|
||||
//设置多曝光模式 0:等差,1:等比
|
||||
int SetMultiExpoMode(int mode);
|
||||
//获取多曝光模式
|
||||
int GetMultiExpoMode();
|
||||
//设置多曝光起点,value 范围:0-100000
|
||||
int SetMultiExpoMin(int value);
|
||||
//获取多曝光起点
|
||||
int GetMultiExpoMin();
|
||||
//设置多曝光终点,value 范围:0-100000
|
||||
int SetMultiExpoMax(int value);
|
||||
//获取多曝光终点
|
||||
int GetMultiExpoMax();
|
||||
//设置增益 model: 1 模拟增益量 2 数据增益量 value: 增益值 times:缺省参数,缺省为1, 第二次增益times = 2 camera_cnt:0是红外, 1是RGB
|
||||
int SetGain(int mode, int value, int camera_cnt);
|
||||
//获取相机增益值 mode: 1 模拟增益量 2 数字增益量 camera_cnt:0是红外, 1是RGB
|
||||
int GetGain(int mode, int camera_cnt);
|
||||
//设置相机触发模式mode: 0 连拍模式 1 触发模式
|
||||
int SetTriggerMode(int mode);
|
||||
//设置相机触发模式信号来源: 0 软触发 1 硬触发
|
||||
int SetTriggerSource(int sourcetype);
|
||||
//设置相机RGB触发模式mode: 0 连拍模式 1 触发模式
|
||||
int SetRGBTriggerMode(int mode);
|
||||
//设置相机触发模式下的触发帧数
|
||||
int SetTriggerCount();
|
||||
//获取相机触发模式下的触发帧数
|
||||
int GetTriggerCount();
|
||||
//设置相机RGB触发模式下的触发帧数
|
||||
int SetRGBTriggerCount();
|
||||
//设置ROI channel_index :数据流通道索引
|
||||
int SetRoi(int channel_index, int size_x, int size_y, int offset_x, int offset_y);
|
||||
//开启数据流通道 channel_index :数据流通道索引
|
||||
int StreamOn(unsigned short channel_index, GigeStream** gigestream);
|
||||
// 设置激光模型 1:line, 0:plane
|
||||
int SetLaserMode(int mode);
|
||||
// 获取激光模型
|
||||
int GetLaserMode();
|
||||
//设置点云后处理模型
|
||||
int SetPointCloudPostProcessMode(int mode);
|
||||
//获取点云后处理模型
|
||||
int GetPointCloudPostProcessMode();
|
||||
//设置点云增益值,取值范围:0-30,只有当点云自动增益等级为0时才可以设置该值
|
||||
int SetPointCloudThresholdValue(int value);
|
||||
//获取点云增益值
|
||||
int GetPointCloudThresholdValue(int* value);
|
||||
//设置点云自动增益等级: 0-20
|
||||
int SetPointCloudThresholdLevel(int level);
|
||||
//获取点云自动增益等级
|
||||
int GetPointCloudThresholdLevel(int* level);
|
||||
// 获取xml buffer size
|
||||
int GetXMLBufferSize(int* size);
|
||||
//获取xml buffer
|
||||
int GetXMLBuffer(char* buffer);
|
||||
//开启或关闭时间戳同步status: 0 关闭时间戳同步 1 开启时间戳同步
|
||||
int SetTimestamp(int status);
|
||||
//获取时间戳是否开启
|
||||
int GetTimestamp();
|
||||
//获取PTPD状态码
|
||||
int GetTimestampStatus();
|
||||
//控制锁存时间戳
|
||||
int SetTimestampControlLatch();
|
||||
//获取时间戳
|
||||
unsigned long long GetTimestampValue();
|
||||
//获取时间戳频率
|
||||
unsigned long long GetTimestampTickFrequency();
|
||||
//开始接受数据
|
||||
int AcquisitionStart(void);
|
||||
//停止接受数据
|
||||
int AcquisitionStop(void);
|
||||
//关闭数据流通道
|
||||
int StreamOff(unsigned short channel_index, GigeStream* gigestream);
|
||||
//相机断开连接
|
||||
int CameraDisconnect();
|
||||
//保存xml到本地
|
||||
int SaveXmlToLocal(std::string pathname);
|
||||
//点云从char *转成float *
|
||||
void Convert3DPointFromCharToFloat(PhotoInfo &raw_data, float* output);
|
||||
//rawdata转RGB888图,输出的数据仍存放在PhotoInfo结构体的pixel中
|
||||
int RawdataToRgb888(PhotoInfo &rgb_data);
|
||||
//点云滤波(基于空间密度的点云去噪)
|
||||
void FilterPointCloud(PhotoInfo &raw_data, double level);
|
||||
//空间滤波(基于空间网格的点云去噪) 20220225: 弃用, FilterPointCloud为该API的升级版
|
||||
int SpatialFilterPointcloud(PhotoInfo &raw_data, int Area_PointCloudCount);
|
||||
//获取点云的X平面数据
|
||||
int GetCloudPlaneX(PhotoInfo &raw_data, short *imagedata);
|
||||
//获取点云的Y平面数据
|
||||
int GetCloudPlaneY(PhotoInfo &raw_data, short *imagedata);
|
||||
//获取点云的Z平面数据
|
||||
int GetCloudPlaneZ(PhotoInfo &raw_data, short *imagedata);
|
||||
//保存点云某个平面数据
|
||||
int SaveCloudPlane(PhotoInfo &raw_data, short *imagedata, char* path_name);
|
||||
//保存点云 to pcd 格式
|
||||
int SavePointCloudToPcd(PhotoInfo &raw_data, char* path_name);
|
||||
//保存点云 to txt 格式
|
||||
int SavePointCloudToTxt(PhotoInfo &raw_data, char* path_name);
|
||||
//保存点云 to ply 格式
|
||||
int SavePointCloudToPly(PhotoInfo &raw_data, char* path_name);
|
||||
//保存BMP图片
|
||||
int SaveToBMP(PhotoInfo &data, char *path_name);
|
||||
//保存点云深度图 to png
|
||||
int SaveDepthToPng(PhotoInfo &raw_data, char* path_name);
|
||||
//点云与图片融合(image_data:图片数据, raw_data:点云数据, image_cloud点云图片融合后的数据, is_filter是否进行滤波,默认滤波)
|
||||
int FusionImageTo3D(PhotoInfo &image_data, PhotoInfo &raw_data, float * image_cloud);
|
||||
//点云RGB进行融合(以RGB为标准重排点云,重排后的点云index对应无畸变的rgb图像)
|
||||
int Fusion3DToRGBWithOutDistortion(PhotoInfo& rgb_data, PhotoInfo& raw_data, PhotoInfo& xyz);
|
||||
//保存与图片融合后的点云txt
|
||||
int SavePointCloudWithImageToTxt(PhotoInfo &raw_data, float * image_cloud, char *path_name);
|
||||
//保存与图片融合后的点云Ply
|
||||
int SavePointCloudWithImageToPly(PhotoInfo &raw_data, float * image_cloud, char *path_name);
|
||||
//保存与图片融合后的点云Pcd
|
||||
int SavePointCloudWithImageToPcd(PhotoInfo &raw_data, float * image_cloud, char *path_name);
|
||||
//相机固件的版本号
|
||||
char* CameraVerion(DiscoveryInfo discovery_info);
|
||||
//SDK的版本号
|
||||
char* SDKVersion();
|
||||
|
||||
//点云RGB进行融合(以RGB为标准重排点云)
|
||||
int Fusion3DToRGB(PhotoInfo &rgb_data, PhotoInfo &raw_data, PhotoInfo &xyz);
|
||||
//固件升级
|
||||
int FirmwareUpgrade(DiscoveryInfo discovery_info, const char *localfilename);
|
||||
//内核升级
|
||||
int KernelUpgrade(DiscoveryInfo discovery_info, const char* localfilename);
|
||||
//获取下位机日志
|
||||
int DownloadCameraLog(DiscoveryInfo discovery_info, const char* path, const char* name);
|
||||
//获取下位机日志目录
|
||||
int CameraLogList(DiscoveryInfo discovery_info, std::vector<std::string>* filename_s, int* len);
|
||||
//根据roi对数据进行裁剪,可以传入rgb和gray数据
|
||||
int ImageRoiCrop(PhotoInfo& source_data, RoiPoint roi, PhotoInfo& target_data);
|
||||
//获取相机盖状态,此接口只对特定型号相机适用, 0:相机盖关闭,1:相机盖打开, 其他:查看错误码
|
||||
int GetCameraCoverStatus(int* status);
|
||||
//打开相机盖,此接口只对特定型号相机适用
|
||||
int TurnOnCameraCover();
|
||||
//关闭相机盖,此接口只对特定型号相机适用
|
||||
int TurnOffCameraCover();
|
||||
// 设置激光器正常/关闭接口,1:关闭,0:正常,默认是正常状态
|
||||
int SetLaserStatus(int status);
|
||||
// 获取激光器正常/关闭接口,1:关闭,0:正常,返回值,0:成功,其他查看错误码
|
||||
int GetLaserStatus(int *status);
|
||||
|
||||
private:
|
||||
#ifdef _WIN32
|
||||
static unsigned int _stdcall HeartBeat(void* arg);
|
||||
#else
|
||||
static void* HeartBeat(void* arg);
|
||||
#endif
|
||||
//读内存
|
||||
int ReadMem(unsigned int mem_addr, unsigned short count, char* recv_buf);
|
||||
//写内存
|
||||
int WriteMem(unsigned int mem_addr, unsigned short count, char* recv_buf);
|
||||
//获取相机xml配置文件
|
||||
int GetXMLfromCamera();
|
||||
////获取节点int类型的属性值
|
||||
//int GetNodeProperty(const char* key, char *property);
|
||||
//协商数据流包大小
|
||||
int GetPacketSize();
|
||||
//YUYV转RGB888图,输出的数据仍存放在PhotoInfo结构体的pixel中
|
||||
int YuyvToRgb888(PhotoInfo &rgb_data);
|
||||
//JPEG转RGB888图,输出的数据仍存放在PhotoInfo结构体的pixel中
|
||||
int JpegToRgb888(PhotoInfo &rgb_data);
|
||||
//BayerRG8转RGB888图,输出的数据仍存放在PhotoInfo结构体的pixel中
|
||||
int BayerRG8ToRgb888(PhotoInfo &rgb_data);
|
||||
//获取点云的某个平面数据
|
||||
int GetCloudPlane(PhotoInfo &raw_data, short *imagedata, int plane);
|
||||
//保存红外图 to bmp 格式
|
||||
int SaveGrayImageToBmp(PhotoInfo &gray_data, char *path_name);
|
||||
//保存rgb图 (RGB888)
|
||||
int SaveRgb888ToBmp(PhotoInfo &rgb_data, char* path_name);
|
||||
//保存rgb图 (RGB565)
|
||||
int SaveRgb565ToBmp(PhotoInfo &rgb_data, char* path_name);
|
||||
//保存rgb图(YUYV)
|
||||
int SaveYuyvRgbToBmp(PhotoInfo &rgb_data, char* path_name);
|
||||
int SaveBayerRG8ToBmp(PhotoInfo &rgb_data, char* path_name);
|
||||
int SaveJpegDataToJpeg(PhotoInfo &rgb_data, char* path_name);
|
||||
//清空socket
|
||||
void flush_socket_buffer(int skt);
|
||||
char *CameraIP(unsigned int Camera_IP);
|
||||
|
||||
private:
|
||||
#ifdef _WIN32
|
||||
//读写寄存器信号量
|
||||
HANDLE rw_reg_sem = NULL;
|
||||
//心跳线程线程句柄
|
||||
HANDLE ccp_thread_id = NULL;
|
||||
#else
|
||||
//读写寄存器信号量
|
||||
sem_t rw_reg_sem;
|
||||
//心跳线程线程ID
|
||||
pthread_t ccp_thread_id = 0;
|
||||
#endif
|
||||
unsigned short req_id_;
|
||||
int camera_num_;
|
||||
int gvcp_socket_id_;
|
||||
int ccp_flag_;
|
||||
//保存相机配置文件xml
|
||||
char* xml_buffer_;
|
||||
//相机配置文件名
|
||||
std::string xml_name_;
|
||||
//相机配置文件xml的后缀: xml or zip
|
||||
std::string xml_extension_;
|
||||
//相机配置文件xml的文件大小
|
||||
int xml_size_;
|
||||
//PC端MTU
|
||||
int mtu_;
|
||||
//流通道索引
|
||||
//unsigned short stream_channel_index_;
|
||||
//接收数据流包大小
|
||||
int pack_size_; //包大小
|
||||
//心跳超时时间
|
||||
int heart_beat_timeout_;
|
||||
//记录主机和客户端信息
|
||||
InstanceDevice device_info_;
|
||||
cameralog logfile;
|
||||
std::vector<CameraParameter> cam_para;
|
||||
//通道和cmos对应关系
|
||||
int* streamList;
|
||||
int* comsList;
|
||||
int streamSize;
|
||||
int comsSize;
|
||||
|
||||
char *camera_ip_;
|
||||
FtpServer ftpserver;
|
||||
public:
|
||||
void *node_map;
|
||||
void *Register_Data;
|
||||
};
|
||||
|
||||
#endif //!DKAM_GIGE_CAMERA_H
|
||||
258
include/dkam_gige_stream.h
Normal file
258
include/dkam_gige_stream.h
Normal file
@@ -0,0 +1,258 @@
|
||||
#pragma once
|
||||
#include "dkam_asyncqueue.h"
|
||||
#include "dkam_base_type.h"
|
||||
#include "dkam_gige_camera.h"
|
||||
#include "dkam_log.h"
|
||||
|
||||
#define GVSP_MAX_INCOMIN_SIZE 65535 //收到数据最大尺寸,其实巨帧也不过9000多个,这最为了方便,直接用16位的最大值 。
|
||||
|
||||
#define SOCKET_SELECT_TIMEOUT_US_DEFAULT 10000 //select超时时间
|
||||
#define PACKET_TIMEOUT_US_DEFAULT 400000 //重发包超时时间
|
||||
#define BLOCK_TIMEOUT_US_DEFAULT 1000000 //block完整性检查评估的超时时间
|
||||
#define PACKET_RESEND_FLAG_DEFAILT TRUE //重发包使用
|
||||
#define PACKET_RESEND_RATIO_DEFAULT 1 //重发比例,默认100%
|
||||
#define MAX_BUFFER_LENGTH_DEFAULT 4 //最长的缓冲区大小,默认4
|
||||
#define NET_SPEED_STATISTICS_UNIT_TIME_US 1000000 //网速计时的默认时间区间,1s
|
||||
#define SEND_TO_SOURCE_SOURCE_TIME_US_DEFAULT 3000000 //默认发包破防火墙的间隔 3s
|
||||
#define MAX_DISCARD_BLOCK_NUM 2000 //最大认为系统丢弃block数量
|
||||
//block数据类型,目前主要用IMAGE
|
||||
typedef enum {
|
||||
BUFFER_PAYLOAD_TYPE_UNKNOWN = -1,
|
||||
BUFFER_PAYLOAD_TYPE_IMAGE = 0x0001,
|
||||
BUFFER_PAYLOAD_TYPE_RAWDATA = 0x0002,
|
||||
BUFFER_PAYLOAD_TYPE_FILE = 0x0003,
|
||||
BUFFER_PAYLOAD_TYPE_CHUNK_DATA = 0x0004,
|
||||
BUFFER_PAYLOAD_TYPE_EXTENDED_CHUNK_DATA = 0x0005, /* Deprecated */
|
||||
BUFFER_PAYLOAD_TYPE_JPEG = 0x0006,
|
||||
BUFFER_PAYLOAD_TYPE_JPEG2000 = 0x0007,
|
||||
BUFFER_PAYLOAD_TYPE_H264 = 0x0008,
|
||||
BUFFER_PAYLOAD_TYPE_MULTIZONE_IMAGE = 0x0009
|
||||
} BufferPayloadType;
|
||||
|
||||
//block收到数据的状态
|
||||
typedef enum {
|
||||
BUFFER_STATUS_SUCCESS = 0,
|
||||
BUFFER_STATUS_UNKNOWN = -1,
|
||||
BUFFER_STATUS_CLEARED = -2,
|
||||
BUFFER_STATUS_TIMEOUT = -3,
|
||||
BUFFER_STATUS_MISSING_PACKETS = -4,
|
||||
BUFFER_STATUS_WRONG_PACKET_ID = -5,
|
||||
BUFFER_STATUS_WRONG_PACKET = -6,
|
||||
BUFFER_STATUS_SIZE_MISMATCH = -7,
|
||||
BUFFER_STATUS_FILLING = -8,
|
||||
BUFFER_STATUS_ABORTED = -9
|
||||
} BufferStatus;
|
||||
|
||||
typedef struct {
|
||||
unsigned short status;
|
||||
unsigned short block_id;
|
||||
unsigned int packet_infos;
|
||||
} GvspHeader;
|
||||
|
||||
typedef struct {
|
||||
unsigned short flags;
|
||||
unsigned short payload_type;
|
||||
unsigned int timestamp_high;
|
||||
unsigned int timestamp_low;
|
||||
unsigned int pixel_format;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int x_offset;
|
||||
unsigned int y_offset;
|
||||
unsigned int gvsp_payload_size;
|
||||
} GvspDataLeader;
|
||||
|
||||
typedef struct {
|
||||
unsigned int payload_type;
|
||||
unsigned int data0;
|
||||
} GvspDataTrailer;
|
||||
|
||||
typedef struct {
|
||||
GvspHeader header;
|
||||
unsigned char data[1];
|
||||
} GvspPacket;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
AsyncQueue *in_buffer;
|
||||
AsyncQueue *out_buffer;
|
||||
}StreamDataBuffer;
|
||||
|
||||
typedef struct {
|
||||
int received; //是否收到包的布尔量
|
||||
long long time_us; //重发该包请求的时间
|
||||
} StreamPacketData;
|
||||
|
||||
typedef struct {
|
||||
PhotoInfo *buffer;
|
||||
unsigned int block_id;
|
||||
|
||||
int buffer_status; //当前包的状态,最好并入到PhotoInfo中,发便用户层查看
|
||||
int last_valid_packet; //连续的有效包中的最后一包,用于重发时检查的起点
|
||||
long long first_packet_time_us; //收到首包的时间,用于后面的统计
|
||||
long long last_packet_time_us; //收到最后一包的时间,在完整性检查是查看是否超时
|
||||
|
||||
int error_packet_received; //收到错误包,以此决定是不是可以将此包送到用户层
|
||||
int packet_resend_num; //每次重发包的次数,避免过多重发包请求干扰正常的GVCP通信。
|
||||
unsigned int n_packets; //一个block的总包数
|
||||
StreamPacketData *packet_data; //每包的信息
|
||||
} StreamBlockData;
|
||||
|
||||
|
||||
class GigeStream
|
||||
{
|
||||
public:
|
||||
GigeStream(DataStreamPrivateInfo *stream_private_info,
|
||||
unsigned short channel_index,
|
||||
int gvsp_socket_id,
|
||||
int interface_address,
|
||||
int device_address,
|
||||
int source_stream_port,
|
||||
int stream_port,
|
||||
int packet_size,
|
||||
long long timestamp_tick_frequency,
|
||||
cameralog *logfile);
|
||||
~GigeStream();
|
||||
int Capture(PhotoInfo *buffer);
|
||||
int TryCapture(PhotoInfo *buffer);
|
||||
int TimeoutCapture(PhotoInfo *buffer, long long timeout);
|
||||
void FlushBuffer();
|
||||
int SetMaxBufferLength(unsigned int length);
|
||||
int GetMaxBufferLength();
|
||||
void SetPacketResendFlag(unsigned int flag);
|
||||
int GetPacketResendFlag();
|
||||
int SetPacketResendRatio(double ratio);
|
||||
double GetPacketResendRatio();
|
||||
int SetSocketSelectTimeout(unsigned int timeout);
|
||||
int GetSocketSelectTimeout();
|
||||
int SetPacketTimeout(unsigned int timeout);
|
||||
int GetPacketTimeout();
|
||||
int SetBlockTimeout(unsigned int timeout);
|
||||
int GetBlockTimeout();
|
||||
int SetSendtoStreamPortBreakFirewallTimeout(unsigned int timeout);
|
||||
int GetSendtoStreamPortBreakFirewallTimeout();
|
||||
|
||||
|
||||
//Statistics();
|
||||
|
||||
void GetBlockStatistics(
|
||||
unsigned int *completed_buffers,
|
||||
unsigned int *failures,
|
||||
unsigned int *timeouts,
|
||||
unsigned int *underruns,
|
||||
unsigned int *aborteds,
|
||||
unsigned int *missing_frames,
|
||||
unsigned int *block_camera_wrong,
|
||||
unsigned int *size_mismatch_errors);
|
||||
|
||||
void GetPacketStatistics(
|
||||
unsigned int *received_packets,
|
||||
unsigned int *missing_packets,
|
||||
unsigned int *error_packets,
|
||||
unsigned int *ignored_packets,
|
||||
unsigned int *resend_requests,
|
||||
unsigned int *resent_packets,
|
||||
unsigned int *duplicated_packets);
|
||||
|
||||
|
||||
void GetRecieveTimeStatistics(StatisticsData *o_statistics_data);
|
||||
int GetNetSpeed();
|
||||
float GetBlockRate();
|
||||
int thread_exit;
|
||||
private:
|
||||
#ifdef _WIN32
|
||||
//接收点云数据线程
|
||||
static unsigned int _stdcall Stream_Thread(void* arg);
|
||||
#else
|
||||
static void* Stream_Thread(void* arg);
|
||||
#endif
|
||||
void loop();
|
||||
|
||||
StreamBlockData* process_packet(GvspPacket *packet, int recv_num, long long time_us);
|
||||
StreamBlockData* find_block_data(GvspPacket *packet, unsigned int block_id, unsigned int packet_id, int recv_num, long long time_us);
|
||||
void process_packet_leader(StreamBlockData *block, GvspPacket *packet, unsigned int packet_id);
|
||||
void process_packet_payload(StreamBlockData *block, GvspPacket *packet, unsigned int packet_id, unsigned int recv_num);
|
||||
void process_packet_tailer(StreamBlockData *block, GvspPacket *packet, unsigned int packet_id);
|
||||
void packet_resend_check(StreamBlockData *block, unsigned int packet_id, long long time_us);
|
||||
void send_packet_request(unsigned int block_id, int resend_first_packet_id, int resend_last_packet_id);
|
||||
void write_recive_data(StreamBlockData *block);
|
||||
void check_block_complete(StreamBlockData *block,long long time_us);
|
||||
void capture_data_process(PhotoInfo *buffer, PhotoInfo *temp_buffer);
|
||||
void flush_blocks();
|
||||
void sendto_stream_source_data();
|
||||
void RecieveTimeStatistics(int data);
|
||||
void NetSpeedStatistics(int recv_num, long long time_us);
|
||||
void BlockRateStatistics(long long time_us);
|
||||
#ifdef _WIN32
|
||||
HANDLE stream_on_thread_id;
|
||||
#else
|
||||
pthread_t stream_on_thread_id;
|
||||
#endif
|
||||
unsigned short channel_index_;
|
||||
StreamDataBuffer stream_data;
|
||||
StatisticsData statistics_data;
|
||||
DataStreamPrivateInfo stream_private_info_;
|
||||
|
||||
List *all_blocks;
|
||||
|
||||
int gvsp_socket_id_;
|
||||
int resend_socket_id_;
|
||||
int interface_address_;
|
||||
//int *interface_socket_address;
|
||||
int device_address_;
|
||||
//int *device_socket_address;
|
||||
struct sockaddr_in resend_addr;
|
||||
struct sockaddr_in sendto_source_addr;
|
||||
unsigned short source_stream_port_;
|
||||
unsigned short stream_port_;
|
||||
long long timestamp_tick_frequency_;
|
||||
|
||||
unsigned short resend_req_id;
|
||||
|
||||
unsigned int last_block_id;
|
||||
unsigned int max_buffer_length_;
|
||||
unsigned int packet_payload_size_;
|
||||
unsigned int max_payload_size_;
|
||||
unsigned int current_buffer_length;
|
||||
|
||||
int packet_resend_flag_;
|
||||
double packet_resend_ratio_;
|
||||
unsigned int socket_select_timeout_us_;
|
||||
unsigned int packet_timeout_us_;
|
||||
unsigned int block_timeout_us_;
|
||||
unsigned int sento_stream_source_time_us_;
|
||||
|
||||
/* Statistics */
|
||||
//block部分的数据统计
|
||||
unsigned int n_completed_buffers;
|
||||
unsigned int n_failures;
|
||||
unsigned int n_timeouts;
|
||||
unsigned int n_underruns;
|
||||
unsigned int n_aborteds;
|
||||
unsigned int n_missing_frames;
|
||||
unsigned int n_block_camera_wrong;
|
||||
|
||||
unsigned int n_size_mismatch_errors;
|
||||
|
||||
//packet部分的数据统计
|
||||
unsigned int n_received_packets;
|
||||
unsigned int n_missing_packets;
|
||||
unsigned int n_error_packets;
|
||||
unsigned int n_ignored_packets;
|
||||
unsigned int n_resend_requests;
|
||||
unsigned int n_resent_packets;
|
||||
unsigned int n_duplicated_packets;
|
||||
|
||||
//网速部分的统计,这里主要是时间,这段时间收到的数据量和以此计算出来的网速;
|
||||
long long n_start_time_us;
|
||||
long long n_recv_num_unit_time;
|
||||
unsigned int n_net_speed;
|
||||
long long n_block_start_time_us;
|
||||
unsigned int n_block_recv_num_unit_time;
|
||||
float n_block_rate;
|
||||
cameralog *logfilestream;
|
||||
//重发包计时
|
||||
time_t start_time_resend;
|
||||
time_t end_time_resend;
|
||||
};
|
||||
|
||||
41
include/dkam_log.h
Normal file
41
include/dkam_log.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//这可以在主函数中直接修改全局变量的值,以便可查找,也可以定义宏变量的值,然后把宏变量的值写一下。
|
||||
extern int gvsp_log_error_level;
|
||||
extern int gvsp_log_warnning_level;
|
||||
extern int gvsp_log_info_level;
|
||||
extern int gvsp_log_debug_level;
|
||||
|
||||
extern int gvcp_log_error_level;
|
||||
extern int gvcp_log_warnning_level;
|
||||
extern int gvcp_log_info_level;
|
||||
extern int gvcp_log_debug_level;
|
||||
|
||||
|
||||
class cameralog {
|
||||
|
||||
public:
|
||||
cameralog();
|
||||
~cameralog();
|
||||
void log_error(int level, const char *format, ...);
|
||||
int log_enable(char *logname);
|
||||
void log_warnning(int level, const char *format, ...);
|
||||
void log_info(int level, const char *format, ...);
|
||||
void log_debug(int level, const char *format, ...);
|
||||
void log_disable(void);
|
||||
|
||||
private:
|
||||
FILE *fd;
|
||||
};
|
||||
#define log_error_gvsp(...) log_error (gvsp_log_error_level, __VA_ARGS__)
|
||||
#define log_warnning_gvsp(...) log_warnning (gvsp_log_warnning_level, __VA_ARGS__)
|
||||
#define log_info_gvsp(...) log_info (gvsp_log_info_level, __VA_ARGS__)
|
||||
#define log_debug_gvsp(...) log_debug (gvsp_log_debug_level, __VA_ARGS__)
|
||||
|
||||
#define log_error_gvcp(...) log_error (gvcp_log_error_level, __VA_ARGS__)
|
||||
#define log_warnning_gvcp(...) log_warnning (gvcp_log_warnning_level, __VA_ARGS__)
|
||||
#define log_info_gvcp(...) log_info (gvcp_log_info_level, __VA_ARGS__)
|
||||
#define log_debug_gvcp(...) log_debug (gvcp_log_debug_level, __VA_ARGS__)
|
||||
|
||||
394
include/dkam_zhicamera_api.h
Normal file
394
include/dkam_zhicamera_api.h
Normal file
@@ -0,0 +1,394 @@
|
||||
/********************************************************************************************
|
||||
Copyright : XianZhisensorTechnologiesCo.,Ltd
|
||||
File Name : zhicamera_api.cpp
|
||||
Description: APIs accessed by users
|
||||
Version :
|
||||
Author : ss.chen
|
||||
Data : 2020-4-16
|
||||
History :
|
||||
*********************************************************************************************/
|
||||
#pragma once
|
||||
#include "dkam_base_type.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
//using namespace std;
|
||||
|
||||
|
||||
typedef struct CAMERA_OBJECT Camera_Object_C;
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DLLEXPORT_API extern __declspec(dllexport)
|
||||
#define DLL_INT int __stdcall
|
||||
#define DLL_CHAR_POINT char* __stdcall
|
||||
#define DLL_BOOL bool __stdcall
|
||||
#define DLL_UNSIGNED_LONG_LONG unsigned long long __stdcall
|
||||
#define DLL_UNSIGNED_INT unsigned int __stdcall
|
||||
#define DLL_VOID void __stdcall
|
||||
#define DLL_CAMERA_OBJECT_POINT Camera_Object_C* __stdcall
|
||||
#define DLL_DISCOVERYINFO DiscoveryInfo __stdcall
|
||||
#define DLL_DOUBLE double __stdcall
|
||||
#define DLL_FLOAT float __stdcall
|
||||
#else
|
||||
#define DLLEXPORT_API
|
||||
#define DLL_INT int
|
||||
#define DLL_CHAR_POINT char*
|
||||
#define DLL_BOOL bool
|
||||
#define DLL_UNSIGNED_LONG_LONG unsigned long long
|
||||
#define DLL_UNSIGNED_INT unsigned int
|
||||
#define DLL_VOID void
|
||||
#define DLL_CAMERA_OBJECT_POINT Camera_Object_C*
|
||||
#define DLL_DISCOVERYINFO DiscoveryInfo
|
||||
#define DLL_DOUBLE double
|
||||
#define DLL_FLOAT float
|
||||
#endif
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
******************************************相机相关操作*****************************************
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
//发现相机
|
||||
DLLEXPORT_API DLL_INT DiscoverCamera();
|
||||
//创建相机
|
||||
DLLEXPORT_API DLL_CAMERA_OBJECT_POINT CreateCamera(int camera_index);
|
||||
//销毁相机
|
||||
DLLEXPORT_API DLL_VOID DestroyCamera(Camera_Object_C* camera_obj);
|
||||
//相机排序(0:IP 1:series number)
|
||||
DLLEXPORT_API DLL_INT CameraSort(int sort_mode);
|
||||
//获取相机的信息
|
||||
DLLEXPORT_API DLL_DISCOVERYINFO GetCameraInfo(Camera_Object_C* camera_obj);
|
||||
//获取相机的CCP状态(data输出0为可连接)
|
||||
DLLEXPORT_API DLL_INT GetCameraCCPStatus(Camera_Object_C* camera_obj, int *data);
|
||||
//获取相机xml所有节点名称
|
||||
DLLEXPORT_API DLL_VOID GetCameraXMLNodeNames(Camera_Object_C* camera_obj, char node_names[][255], int* len);
|
||||
//获取节点最大值
|
||||
DLLEXPORT_API DLL_INT GetNodeMaxValue(Camera_Object_C* camera_obj, const char* key);
|
||||
//获取节点最小值
|
||||
DLLEXPORT_API DLL_INT GetNodeMinValue(Camera_Object_C* camera_obj, const char* key);
|
||||
//获取int节点增量
|
||||
DLLEXPORT_API DLL_INT GetNodeIncValue(Camera_Object_C* camera_obj, const char* key);
|
||||
//获取相机节点value(camera_ret:相机索引号 key:寄存器的名称)
|
||||
DLLEXPORT_API DLL_INT GetRegisterAddr(Camera_Object_C* camera_obj, const char* key);
|
||||
//读string类型的寄存器
|
||||
DLLEXPORT_API DLL_INT ReadStringRegister(Camera_Object_C* camera_obj, const char* key, char* reg_str);
|
||||
//写string类型的寄存器
|
||||
DLLEXPORT_API DLL_INT WriteStringRegister(Camera_Object_C* camera_obj, const char* key, unsigned short datasize, char* reg_str);
|
||||
//相机IP(camera_ret:相机索引号)
|
||||
DLLEXPORT_API DLL_CHAR_POINT CameraIP(int camera_index);
|
||||
//相机的序列号
|
||||
DLLEXPORT_API DLL_CHAR_POINT CameraSeriesNumberByIndex(int camera_index);
|
||||
//设置log日志的等级开关,决定是否开启某一个等级的日志打印,默认关闭(0:关闭 1:开启)
|
||||
DLLEXPORT_API DLL_VOID SetLogLevel(int error, int debug, int warnning, int info);
|
||||
//连接相机(camera_ret:相机索引号)
|
||||
DLLEXPORT_API DLL_INT CameraConnect(Camera_Object_C* camera_obj);
|
||||
//开启数据流通道 (camera_ret:相机索引号 channel_index :数据流通道索引)
|
||||
DLLEXPORT_API DLL_INT StreamOn(Camera_Object_C* camera_obj, unsigned short channel_index);
|
||||
//开始接受数据 (camera_ret:相机索引号)
|
||||
DLLEXPORT_API DLL_INT AcquisitionStart(Camera_Object_C* camera_obj);
|
||||
//清空缓存区
|
||||
DLLEXPORT_API DLL_VOID FlushBuffer(Camera_Object_C* camera_obj, unsigned short channel_index);
|
||||
//设置最大的缓冲区
|
||||
DLLEXPORT_API DLL_INT SetMaxBufferLength(Camera_Object_C* camera_obj, unsigned short channel_index, unsigned int size);
|
||||
//获取buffer缓冲区大小
|
||||
DLLEXPORT_API DLL_INT GetMaxBufferLength(Camera_Object_C* camera_obj, unsigned short channel_index);
|
||||
//设置重发包比例
|
||||
DLLEXPORT_API DLL_INT SetPacketResendRatio(Camera_Object_C* camera_obj, unsigned short channel_index, double ratio);
|
||||
//获取重发包比例
|
||||
DLLEXPORT_API DLL_DOUBLE GetPacketResendRatio(Camera_Object_C* camera_obj, unsigned short channel_index);
|
||||
//设置select的超时时间
|
||||
DLLEXPORT_API DLL_INT SetSocketSelectTimeout(Camera_Object_C* camera_obj, unsigned short channel_index, unsigned int timeout);
|
||||
//获取select的超时时间
|
||||
DLLEXPORT_API DLL_INT GetSocketSelectTimeout(Camera_Object_C* camera_obj, unsigned short channel_index);
|
||||
//设置重发包超时时间
|
||||
DLLEXPORT_API DLL_INT SetPacketTimeout(Camera_Object_C* camera_obj, unsigned short channel_index, unsigned int timeout);
|
||||
//获取重发包超时时间
|
||||
DLLEXPORT_API DLL_INT GetPacketTimeout(Camera_Object_C* camera_obj, unsigned short channel_index);
|
||||
//设置block超时时间
|
||||
DLLEXPORT_API DLL_INT SetBlockTimeout(Camera_Object_C* camera_obj, unsigned short channel_index, unsigned int timeout);
|
||||
//获取block超时时间
|
||||
DLLEXPORT_API DLL_INT GetBlockTimeout(Camera_Object_C* camera_obj, unsigned short channel_index);
|
||||
//获取帧方面的统计数据
|
||||
DLLEXPORT_API DLL_VOID GetBlockStatistics(Camera_Object_C* camera_obj, unsigned short channel_index,
|
||||
unsigned int *completed_buffers,
|
||||
unsigned int *failures,
|
||||
unsigned int *timeouts,
|
||||
unsigned int *underruns,
|
||||
unsigned int *aborteds,
|
||||
unsigned int *missing_frames,
|
||||
unsigned int *block_camera_wrong,
|
||||
unsigned int *size_mismatch_errors);
|
||||
//获取包方面的统计数据
|
||||
DLLEXPORT_API DLL_VOID GetPacketStatistics(Camera_Object_C* camera_obj, unsigned short channel_index,
|
||||
unsigned int *received_packets,
|
||||
unsigned int *missing_packets,
|
||||
unsigned int *error_packets,
|
||||
unsigned int *ignored_packets,
|
||||
unsigned int *resend_requests,
|
||||
unsigned int *resent_packets,
|
||||
unsigned int *duplicated_packets);
|
||||
//获取接收花费时间方面的统计数据
|
||||
DLLEXPORT_API DLL_VOID GetRecieveTimeStatistics(Camera_Object_C* camera_obj, unsigned short channel_index, StatisticsData *o_statistics_data);
|
||||
//获取网速的统计数据
|
||||
DLLEXPORT_API DLL_INT GetNetSpeed(Camera_Object_C* camera_obj, unsigned short channel_index);
|
||||
//获取帧率的统计数据
|
||||
DLLEXPORT_API DLL_FLOAT GetBlockRate(Camera_Object_C* camera_obj, unsigned short channel_index);
|
||||
//获取数据(camera_ret:相机索引号 channel_index :数据流通道索引 raw_data:接收数据的结构体 )
|
||||
/*C++*/
|
||||
//阻塞式抓取数据
|
||||
DLLEXPORT_API DLL_INT Capture(Camera_Object_C* camera_obj, unsigned short channel_index, PhotoInfo *raw_data);
|
||||
//try
|
||||
DLLEXPORT_API DLL_INT TryCapture(Camera_Object_C* camera_obj, unsigned short channel_index, PhotoInfo *raw_data);
|
||||
//超时抓取数据
|
||||
DLLEXPORT_API DLL_INT TimeoutCapture(Camera_Object_C* camera_obj, unsigned short channel_index, PhotoInfo *raw_data, long long timeout);
|
||||
//将char数据转为float类型
|
||||
DLLEXPORT_API DLL_VOID Convert3DPointFromCharToFloat(Camera_Object_C* camera_obj, PhotoInfo *raw_data, float* output);
|
||||
//将Rawdata数据转换成RGB888的图像数据
|
||||
DLLEXPORT_API DLL_INT RawdataToRgb888(Camera_Object_C* camera_obj, PhotoInfo *rgb_data);
|
||||
//获取点云的X平面数据
|
||||
DLLEXPORT_API DLL_INT GetCloudPlaneX(Camera_Object_C* camera_obj, PhotoInfo *raw_data, short *imagedata);
|
||||
//获取点云的Y平面数据
|
||||
DLLEXPORT_API DLL_INT GetCloudPlaneY(Camera_Object_C* camera_obj, PhotoInfo *raw_data, short *imagedata);
|
||||
//获取点云的Z平面数据
|
||||
DLLEXPORT_API DLL_INT GetCloudPlaneZ(Camera_Object_C* camera_obj, PhotoInfo *raw_data, short *imagedata);
|
||||
//保存点云某个平面数据
|
||||
DLLEXPORT_API DLL_INT SaveCloudPlane(Camera_Object_C* camera_obj, PhotoInfo *raw_data, short *imagedata, char* path_name);
|
||||
/*C++*/
|
||||
|
||||
//停止接受数据(camera_ret:相机索引号)
|
||||
DLLEXPORT_API DLL_INT AcquisitionStop(Camera_Object_C* camera_obj);
|
||||
//关闭数据流通道 (camera_ret:相机索引号 channel_index :数据流通道索引)
|
||||
DLLEXPORT_API DLL_INT StreamOff(Camera_Object_C* camera_obj, unsigned short channel_index);
|
||||
//相机断开连接 (camera_ret:相机索引号)
|
||||
DLLEXPORT_API DLL_INT CameraDisconnect(Camera_Object_C* camera_obj);
|
||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
****************************************GVCP相关操作*******************************************
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
//获取相机内参
|
||||
DLLEXPORT_API DLL_INT GetCamInternelParameter(Camera_Object_C* camera_obj, int camera_cnt, float *Kc, float *K);
|
||||
//获取相机外参
|
||||
DLLEXPORT_API DLL_INT GetCamExternelParameter(Camera_Object_C* camera_obj, int camera_cnt, float *R, float *T);
|
||||
//设置相机ip (camera_ret:相机索引号 ip mask gateway)
|
||||
DLLEXPORT_API DLL_INT ForceIP(Camera_Object_C* camera_obj, char* ip, char* mask, char* gateway);
|
||||
//判断相机的IP和PC的IP是否在同一网段
|
||||
DLLEXPORT_API DLL_BOOL WhetherIsSameSegment(Camera_Object_C* camera_obj);
|
||||
//设置相机种类 (0:红外;1:RGB)
|
||||
DLLEXPORT_API DLL_INT SetCameraType(Camera_Object_C* camera_obj, int camera_cnt);
|
||||
//获取相机种类 (0:红外;1:RGB)
|
||||
DLLEXPORT_API DLL_INT GetCameraType(Camera_Object_C* camera_obj);
|
||||
//获取相机的宽
|
||||
DLLEXPORT_API DLL_INT GetCameraWidth(Camera_Object_C* camera_obj, int* width, int camera_cnt);
|
||||
//设置相机的宽
|
||||
DLLEXPORT_API DLL_INT SetCameraWidth(Camera_Object_C* camera_obj, int width, int camera_cnt);
|
||||
//获取相机的高
|
||||
DLLEXPORT_API DLL_INT GetCameraHeight(Camera_Object_C* camera_obj, int* height, int camera_cnt);
|
||||
//设置相机的高
|
||||
DLLEXPORT_API DLL_INT SetCameraHeight(Camera_Object_C* camera_obj, int height, int camera_cnt);
|
||||
//写寄存器 (camera_ret:相机索引号 register_addr:寄存器的地址 data:接收寄存器的值)
|
||||
DLLEXPORT_API DLL_INT WriteRegister(Camera_Object_C* camera_obj, unsigned int register_addr, int data);
|
||||
//读寄存器 (camera_ret:相机索引号 register_addr:寄存器的地址 data:接收寄存器的值)
|
||||
DLLEXPORT_API DLL_INT ReadRegister(Camera_Object_C* camera_obj, unsigned int register_addr, int* data);
|
||||
//设置超时时间
|
||||
DLLEXPORT_API DLL_INT SetHeartBeatTimeout(Camera_Object_C* camera_obj, int value);
|
||||
//获取超时时间
|
||||
DLLEXPORT_API DLL_INT GetHeartBeatTimeout(Camera_Object_C* camera_obj);
|
||||
//设置相机曝光模式(camera_index:相机索引号 status:(1手动曝光,0自动曝光) camera_cnt:相机的摄像头0:红外摄像头 1:RGB摄像头)
|
||||
DLLEXPORT_API DLL_INT SetAutoExposure(Camera_Object_C* camera_obj, int status, int camera_cnt);
|
||||
//获取相机曝光模式 (camera_index:相机索引号 camera_cnt:相机的摄像头0:红外摄像头 1:RGB摄像头)
|
||||
DLLEXPORT_API DLL_INT GetAutoExposure(Camera_Object_C* camera_obj, int camera_cnt);
|
||||
//设置RGB摄像头自动曝光增益的级别(>=1 仅支持RGB摄像头) (camera_index:相机索引号 camera_cnt:相机的摄像头0:红外摄像头 1:RGB摄像头 level:曝光增益等级)
|
||||
DLLEXPORT_API DLL_INT SetCamExposureGainLevel(Camera_Object_C* camera_obj, int camera_cnt, int level);
|
||||
//获取RGB摄像头自动曝光增益的级别,仅支持RGB摄像头(camera_index:相机索引号 camera_cnt:相机的摄像头0:红外摄像头 1:RGB摄像头)
|
||||
DLLEXPORT_API DLL_INT GetCamExposureGainLevel(Camera_Object_C* camera_obj, int camera_cnt);
|
||||
//设置相机曝光类型int status >0 多重曝光 不能是0
|
||||
DLLEXPORT_API DLL_INT SetMutipleExposure(Camera_Object_C* camera_obj, int status);
|
||||
//获取相机曝光类型
|
||||
DLLEXPORT_API DLL_INT GetMutipleExposure(Camera_Object_C* camera_obj);
|
||||
//设置曝光时间utimes:曝光时间: 红外镜头范围1000 - 100000um, RGB镜头范围1000 - 56000um, 默认16600, camera_cnt:0是红外, 1是RGB
|
||||
DLLEXPORT_API DLL_INT SetExposureTime(Camera_Object_C* camera_obj, int utime, int camera_cnt);
|
||||
//获取相机曝光时间 camera_cnt:0是红外, 1是RGB
|
||||
DLLEXPORT_API DLL_INT GetExposureTime(Camera_Object_C* camera_obj, int camera_cnt);
|
||||
//设置相机多曝光模式, 0:等差,1:等比
|
||||
DLLEXPORT_API DLL_INT SetMultiExpoMode(Camera_Object_C* camera_obj, int mode);
|
||||
//获取相机多曝光模式
|
||||
DLLEXPORT_API DLL_INT GetMultiExpoMode(Camera_Object_C* camera_obj);
|
||||
//设置多曝光起点,value 范围:0-100000
|
||||
DLLEXPORT_API DLL_INT SetMultiExpoMin(Camera_Object_C* camera_obj, int value);
|
||||
//获取多曝光起点
|
||||
DLLEXPORT_API DLL_INT GetMultiExpoMin(Camera_Object_C* camera_obj);
|
||||
//设置多曝光终点,value 范围:0-100000
|
||||
DLLEXPORT_API DLL_INT SetMultiExpoMax(Camera_Object_C* camera_obj, int value);
|
||||
//获取多曝光终点
|
||||
DLLEXPORT_API DLL_INT GetMultiExpoMax(Camera_Object_C* camera_obj);
|
||||
//设置增益 model: 1 模拟增益量 2 数据增益量 value: 增益值 times:缺省参数,缺省为1, 第二次增益times = 2
|
||||
DLLEXPORT_API DLL_INT SetGain(Camera_Object_C* camera_obj, int mode, int value, int camera_cnt);
|
||||
//获取相机增益值 mode: 1 模拟增益量 2 数据增益量
|
||||
DLLEXPORT_API DLL_INT GetGain(Camera_Object_C* camera_obj, int mode, int camera_cnt);
|
||||
//设置相机触发模式mode: 0 连拍模式 1 触发模式
|
||||
DLLEXPORT_API DLL_INT SetTriggerMode(Camera_Object_C* camera_obj, int mode);
|
||||
//设置相机触发模式信号来源: 0 软触发 1 硬触发
|
||||
DLLEXPORT_API DLL_INT SetTriggerSource(Camera_Object_C* camera_obj, int sourcetype);
|
||||
//设置相机RGB触发模式mode: 0 连拍模式 1 触发模式
|
||||
DLLEXPORT_API DLL_INT SetRGBTriggerMode(Camera_Object_C* camera_obj, int mode);
|
||||
//设置相机触发模式下的触发帧数
|
||||
DLLEXPORT_API DLL_INT SetTriggerCount(Camera_Object_C* camera_obj);
|
||||
//获取相机触发模式下的触发帧数
|
||||
DLLEXPORT_API DLL_INT GetTriggerCount(Camera_Object_C* camera_obj);
|
||||
//设置相机RGB触发模式下的触发帧数
|
||||
DLLEXPORT_API DLL_INT SetRGBTriggerCount(Camera_Object_C* camera_obj);
|
||||
//设置重发请求: 0 关闭, 1 打开(默认开启)
|
||||
DLLEXPORT_API DLL_VOID SetResendRequest(Camera_Object_C* camera_obj, int channel_index, int resend_flag);
|
||||
//获取重发请求: 0 关闭, 1 打开(默认开启)
|
||||
DLLEXPORT_API DLL_INT GetResendRequest(Camera_Object_C* camera_obj, int channel_index);
|
||||
//设置红外摄像头ROI
|
||||
DLLEXPORT_API DLL_INT SetRoi(Camera_Object_C* camera_obj, int channel_index, int size_x, int size_y, int offset_x, int offset_y);
|
||||
//设置激光模式: 1 line, 0 plane(默认plane)
|
||||
DLLEXPORT_API DLL_INT SetLaserMode(Camera_Object_C* camera_obj, int mode);
|
||||
//获取激光模式
|
||||
DLLEXPORT_API DLL_INT GetLaserMode(Camera_Object_C* camera_obj);
|
||||
//设置点云后处理模型
|
||||
DLLEXPORT_API DLL_INT SetPointCloudPostProcessMode(Camera_Object_C* camera_obj, int mode);
|
||||
//获取点云后处理模型
|
||||
DLLEXPORT_API DLL_INT GetPointCloudPostProcessMode(Camera_Object_C* camera_obj);
|
||||
//设置点云增益值,取值范围:0-30,只有当点云自动增益等级为0时才可以设置该值
|
||||
DLLEXPORT_API DLL_INT SetPointCloudThresholdValue(Camera_Object_C* camera_obj, int value);
|
||||
//获取点云增益值
|
||||
DLLEXPORT_API DLL_INT GetPointCloudThresholdValue(Camera_Object_C* camera_obj, int* value);
|
||||
//设置点云自动增益等级: 0-20
|
||||
DLLEXPORT_API DLL_INT SetPointCloudThresholdLevel(Camera_Object_C* camera_obj, int level);
|
||||
//获取点云自动增益等级
|
||||
DLLEXPORT_API DLL_INT GetPointCloudThresholdLevel(Camera_Object_C* camera_obj, int* level);
|
||||
//获取xml buffer size
|
||||
DLLEXPORT_API DLL_INT GetXMLBufferSize(Camera_Object_C* camera_obj, int* xml_size);
|
||||
//获取xml buffer
|
||||
DLLEXPORT_API DLL_INT GetXMLBuffer(Camera_Object_C* camera_obj, char* buffer);
|
||||
//保存用户配置文件
|
||||
DLLEXPORT_API DLL_INT SaveUserConfig(Camera_Object_C* camera_obj, char* fliename);
|
||||
//加载用户配置文件
|
||||
DLLEXPORT_API DLL_INT LoadUserConfig(Camera_Object_C* camera_obj,char* fliename);
|
||||
//获取节点类型
|
||||
DLLEXPORT_API DLL_INT GetNodeType(Camera_Object_C* camera_obj, const char* key);
|
||||
//获取节点访问模式
|
||||
DLLEXPORT_API DLL_INT GetNodeAccessMode(Camera_Object_C* camera_obj, const char* key);
|
||||
//设置Int类型节点值
|
||||
DLLEXPORT_API DLL_INT SetIntNodeValue(Camera_Object_C* camera_obj, const char* key, unsigned int value);
|
||||
//设置Bool类型节点值
|
||||
DLLEXPORT_API DLL_INT SetBoolNodeValue(Camera_Object_C* camera_obj, const char* key, bool value);
|
||||
//设置Command类型节点值
|
||||
DLLEXPORT_API DLL_INT SetCommandNodeValue(Camera_Object_C* camera_obj, const char* key);
|
||||
//设置Float类型节点值
|
||||
DLLEXPORT_API DLL_INT SetFloatNodeValue(Camera_Object_C* camera_obj, const char* key, float value);
|
||||
//设置String类型节点值
|
||||
DLLEXPORT_API DLL_INT SetStringNodeValue(Camera_Object_C* camera_obj, const char* key, char* value);
|
||||
//设置Enumeration类型节点值
|
||||
DLLEXPORT_API DLL_INT SetEnumNodeValue(Camera_Object_C* camera_obj, const char* key, int value);
|
||||
//获取Int类型节点值
|
||||
DLLEXPORT_API DLL_INT GetIntNodeValue(Camera_Object_C* camera_obj, const char* key, int* value);
|
||||
//获取Bool类型节点值
|
||||
DLLEXPORT_API DLL_INT GetBoolNodeValue(Camera_Object_C* camera_obj, const char* key, int* value);
|
||||
//获取Command类型节点值
|
||||
DLLEXPORT_API DLL_INT GetCommandNodeValue(Camera_Object_C* camera_obj, const char* key, char* value);
|
||||
//获取Float类型节点值
|
||||
DLLEXPORT_API DLL_INT GetFloatNodeValue(Camera_Object_C* camera_obj, const char* key, float* value);
|
||||
//获取String类型节点值
|
||||
DLLEXPORT_API DLL_INT GetStringNodeValue(Camera_Object_C* camera_obj, const char* key, char* value);
|
||||
//获取Enumeration类型节点值
|
||||
DLLEXPORT_API DLL_INT GetEnumNodeValue(Camera_Object_C* camera_obj, const char* key, int* value);
|
||||
//开启或关闭时间戳同步status: 0 关闭时间戳同步 1 开启时间戳同步
|
||||
DLLEXPORT_API DLL_INT SetTimestamp(Camera_Object_C* camera_obj, int status);
|
||||
//获取时间戳是否开启
|
||||
DLLEXPORT_API DLL_INT GetTimestamp(Camera_Object_C* camera_obj);
|
||||
//获取PTPD状态码
|
||||
DLLEXPORT_API DLL_INT GetTimestampStatus(Camera_Object_C* camera_obj);
|
||||
//控制锁存时间戳
|
||||
DLLEXPORT_API DLL_INT SetTimestampControlLatch(Camera_Object_C* camera_obj);
|
||||
//获取时间戳
|
||||
DLLEXPORT_API DLL_UNSIGNED_LONG_LONG GetTimestampValue(Camera_Object_C* camera_obj);
|
||||
//获取时间戳频率
|
||||
DLLEXPORT_API DLL_UNSIGNED_LONG_LONG GetTimestampTickFrequency(Camera_Object_C* camera_obj);
|
||||
//固件升级
|
||||
DLLEXPORT_API DLL_INT FirmwareUpgrade(Camera_Object_C* camera_obj, const char *localfilename);
|
||||
//内核升级
|
||||
DLLEXPORT_API DLL_INT KernelUpgrade(Camera_Object_C* camera_obj, const char* localfilename);
|
||||
//获取下位置日志
|
||||
DLLEXPORT_API DLL_INT DownloadCameraLog(Camera_Object_C* camera_obj, const char* filepath, const char* filename);
|
||||
//获取下位机日志目录
|
||||
DLLEXPORT_API DLL_INT CameraLogList(Camera_Object_C* camera_obj, char filename_s[][255], int* len);
|
||||
//图片裁剪
|
||||
DLLEXPORT_API DLL_INT ImageRoiCrop(Camera_Object_C* camera_obj, PhotoInfo* source_data, RoiPoint roi, PhotoInfo* target_data);
|
||||
//获取相机盖状态,此接口只对特定型号相机适用, 0:相机盖关闭,1:相机盖打开, 其他:查看错误码
|
||||
DLLEXPORT_API DLL_INT GetCameraCoverStatus(Camera_Object_C* camera_obj, int* status);
|
||||
//相机盖状态,此接口只对特定型号相机适用
|
||||
DLLEXPORT_API DLL_INT TurnOnCameraCover(Camera_Object_C* camera_obj);
|
||||
//关闭相机盖,此接口只对特定型号相机适用
|
||||
DLLEXPORT_API DLL_INT TurnOffCameraCover(Camera_Object_C* camera_obj);
|
||||
// 设置激光器正常/关闭接口,1:关闭,0:正常,默认是正常状态
|
||||
DLLEXPORT_API DLL_INT SetLaserStatus(Camera_Object_C* camera_obj, int status);
|
||||
// 获取激光器正常/关闭接口,1:关闭,0:正常,返回值,0:成功,其他查看错误码
|
||||
DLLEXPORT_API DLL_INT GetLaserStatus(Camera_Object_C* camera_obj, int* status);
|
||||
|
||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
*******************************************数据保存********************************************
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
//保存xml到本地
|
||||
DLLEXPORT_API DLL_INT SaveXmlToLocal(Camera_Object_C* camera_obj, char* pathname);
|
||||
/*C++*/
|
||||
//保存点云 to pcd 格式
|
||||
DLLEXPORT_API DLL_INT SavePointCloudToPcd(Camera_Object_C* camera_obj, PhotoInfo *raw_data, char* path_name);
|
||||
//保存点云 to txt 格式
|
||||
DLLEXPORT_API DLL_INT SavePointCloudToTxt(Camera_Object_C* camera_obj, PhotoInfo *raw_data, char* path_name);
|
||||
//保存点云 to ply 格式
|
||||
DLLEXPORT_API DLL_INT SavePointCloudToPly(Camera_Object_C* camera_obj, PhotoInfo *raw_data, char* path_name);
|
||||
//点云滤波(基于空间密度的点云去噪)
|
||||
DLLEXPORT_API DLL_VOID FilterPointCloud(Camera_Object_C* camera_obj, PhotoInfo *raw_data, double level);
|
||||
//空间滤波(基于空间网格的点云去噪) 20220225: 弃用, FilterPointCloud为该API的升级版
|
||||
DLLEXPORT_API DLL_INT SpatialFilterPointcloud(Camera_Object_C* camera_obj, PhotoInfo *raw_data, int Area_PointCloudCount);
|
||||
//保存bmp图
|
||||
DLLEXPORT_API DLL_INT SaveToBMP(Camera_Object_C* camera_obj, PhotoInfo *data, char* path_name);
|
||||
//保存点云深度图 to png
|
||||
DLLEXPORT_API DLL_INT SaveDepthToPng(Camera_Object_C* camera_obj, PhotoInfo *raw_data, char* path_name);
|
||||
//点云融合
|
||||
DLLEXPORT_API DLL_INT FusionImageTo3D(Camera_Object_C* camera_obj, PhotoInfo *image_data, PhotoInfo *raw_data, float * image_cloud);
|
||||
//根据RGB重排点云
|
||||
DLLEXPORT_API DLL_INT Fusion3DToRGB(Camera_Object_C* camera_obj, PhotoInfo *rgb_data, PhotoInfo *raw_data, PhotoInfo *xyz);
|
||||
//根据RGB重排点云
|
||||
DLLEXPORT_API DLL_INT Fusion3DToRGBWithOutDistortion(Camera_Object_C* camera_obj, PhotoInfo* rgb_data, PhotoInfo* raw_data, PhotoInfo* xyz);
|
||||
//图像膨胀
|
||||
DLLEXPORT_API DLL_VOID PixelSwell(Camera_Object_C* camera_obj, int *roi_output, PhotoInfo *target_data);
|
||||
//图像腐蚀
|
||||
DLLEXPORT_API DLL_VOID PixelCorrosion(Camera_Object_C* camera_obj, int *roi_output, PhotoInfo *target_data);
|
||||
//ROI映射区域坐标
|
||||
DLLEXPORT_API DLL_VOID ROIMappingCoordinate(Camera_Object_C* camera_obj, int *roi_output, PhotoInfo *target_data, RoiPoint *point_output);
|
||||
//ROI检索映射
|
||||
DLLEXPORT_API DLL_VOID ROIPixelMapping(Camera_Object_C* camera_obj, PhotoInfo *point_data, PhotoInfo *source_data, PhotoInfo *target_data, RoiPoint *roi_input, int *ROI_output);
|
||||
//保存点云 with image to pcd
|
||||
DLLEXPORT_API DLL_INT SavePointCloudWithImageToTxt(Camera_Object_C* camera_obj, PhotoInfo *raw_data, float * rgb_cloud, char *path_name);
|
||||
//保存与图片融合后的点云Ply(保留无效点)
|
||||
DLLEXPORT_API DLL_INT SavePointCloudWithImageToPly(Camera_Object_C* camera_obj, PhotoInfo *raw_data, float * image_cloud, char *path_name);
|
||||
//保存与图片融合后的点云Pcd
|
||||
DLLEXPORT_API DLL_INT SavePointCloudWithImageToPcd(Camera_Object_C* camera_obj, PhotoInfo *raw_data, float * image_cloud, char *path_name);
|
||||
/*C++*/
|
||||
/*/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
*******************************************获取版本号******************************************
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////*/
|
||||
//相机固件的版本号
|
||||
DLLEXPORT_API DLL_CHAR_POINT CameraVerions(Camera_Object_C* camera_obj);
|
||||
//SDK的版本号
|
||||
DLLEXPORT_API DLL_CHAR_POINT SDKVersion(Camera_Object_C* camera_obj);
|
||||
DLLEXPORT_API DLL_CHAR_POINT sdkversion();
|
||||
//相机的序列号
|
||||
DLLEXPORT_API DLL_CHAR_POINT CameraSeriesNumber(Camera_Object_C* camera_obj);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
93
include/dkam_zhicamera_api_csharp.h
Normal file
93
include/dkam_zhicamera_api_csharp.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#pragma once
|
||||
|
||||
#include "dkam_base_type.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DLLEXPORT_API extern __declspec(dllexport)
|
||||
#define DLL_VOID void __stdcall
|
||||
#define DLL_INT int __stdcall
|
||||
#else
|
||||
#define DLLEXPORT_API
|
||||
#define DLL_VOID void
|
||||
#define DLL_INT int
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
/*C#*/
|
||||
DLLEXPORT_API DLL_VOID GetCameraXMLNodeNamesCSharp(Camera_Object_C* camera_obj, std::vector<std::string>* node_names);
|
||||
//获取下位机日志目录
|
||||
DLLEXPORT_API DLL_INT CameraLogListCSharp(Camera_Object_C* camera_obj, std::vector<std::string>* file_names, int* len);
|
||||
//阻塞式抓取数据
|
||||
DLLEXPORT_API DLL_INT CaptureCSharp(Camera_Object_C* camera_obj, unsigned short channel_index, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size);
|
||||
//try
|
||||
DLLEXPORT_API DLL_INT TryCaptureCSharp(Camera_Object_C* camera_obj, unsigned short channel_index, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size);
|
||||
//超时抓取数据
|
||||
DLLEXPORT_API DLL_INT TimeoutCaptureCSharp(Camera_Object_C* camera_obj, unsigned short channel_index, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, long long timeout);
|
||||
//将char数据转为float类型
|
||||
DLLEXPORT_API DLL_VOID Convert3DPointFromCharToFloatCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, float* output,int outputsize);
|
||||
//将Rawdata数据转换成RGB888的图像数据
|
||||
DLLEXPORT_API DLL_VOID RawdataToRgb888CSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size);
|
||||
//获取点云的X平面数据
|
||||
DLLEXPORT_API DLL_INT GetCloudPlaneXCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, short *imagedata, int datasize);
|
||||
//获取点云的Y平面数据
|
||||
DLLEXPORT_API DLL_INT GetCloudPlaneYCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, short *imagedata, int datasize);
|
||||
//获取点云的Z平面数据
|
||||
DLLEXPORT_API DLL_INT GetCloudPlaneZCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, short *imagedata, int datasize);
|
||||
//保存点云某个平面数据
|
||||
DLLEXPORT_API DLL_INT SaveCloudPlaneCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, short *imagedata, int datasize, char* path_name);
|
||||
//保存点云 to pcd 格式
|
||||
DLLEXPORT_API DLL_INT SavePointCloudToPcdCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, char* path_name);
|
||||
//保存点云 to txt 格式
|
||||
DLLEXPORT_API DLL_INT SavePointCloudToTxtCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, char* path_name);
|
||||
//保存点云 to ply 格式
|
||||
DLLEXPORT_API DLL_INT SavePointCloudToPlyCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, char* path_name);
|
||||
//点云滤波(基于空间密度的点云去噪)
|
||||
DLLEXPORT_API DLL_VOID FilterPointCloudCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, double level);
|
||||
//空间滤波(基于空间网格的点云去噪) 20220225: 弃用, FilterPointCloud为该API的升级版
|
||||
DLLEXPORT_API DLL_INT SpatialFilterPointcloudCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, int Area_PointCloudCount);
|
||||
//保存bmp图
|
||||
DLLEXPORT_API DLL_INT SaveToBMPCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, char *path_name);
|
||||
//图片裁剪
|
||||
DLLEXPORT_API DLL_INT ImageRoiCropCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp& source_data, char* source_pixel, int source_size, RoiPoint roi, PhotoInfoCSharp& target_data, char* target_pixel, int target_size);
|
||||
//保存点云深度图 to png
|
||||
DLLEXPORT_API DLL_INT SaveDepthToPngCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &raw_data_info, char *xyz, int pixel_size, char* path_name);
|
||||
//点云融合
|
||||
DLLEXPORT_API DLL_INT FusionImageTo3DCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &image_data_info, char *image_pixel, int image_pixel_size,
|
||||
PhotoInfoCSharp &point_data_info, char *point_pixel, int point_pixel_size, float * image_cloud, int image_cloud_size);
|
||||
//根据RGB重排点云
|
||||
DLLEXPORT_API DLL_INT Fusion3DToRGBCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &image_data_info, char *image_pixel, int image_pixel_size,
|
||||
PhotoInfoCSharp &point_data_info, char *point_pixel, int point_pixel_size,
|
||||
PhotoInfoCSharp &xyz_data_info, char *xyz, int xyz_size);
|
||||
//根据RGB重排点云
|
||||
DLLEXPORT_API DLL_INT Fusion3DToRGBWithOutDistortionCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp& image_data_info, char* image_pixel, int image_pixel_size,
|
||||
PhotoInfoCSharp& point_data_info, char* point_pixel, int point_pixel_size,
|
||||
PhotoInfoCSharp& xyz_data_info, char* xyz, int xyz_size);
|
||||
//图像膨胀
|
||||
DLLEXPORT_API DLL_VOID PixelSwellCSharp(Camera_Object_C* camera_obj, int roi_output_size, int *roi_output, PhotoInfoCSharp &target_data, int target_pixel_size);
|
||||
//图像腐蚀
|
||||
DLLEXPORT_API DLL_VOID PixelCorrosionCSharp(Camera_Object_C* camera_obj, int roi_output_size, int *roi_output, PhotoInfoCSharp &target_data, int target_pixel_size);
|
||||
//ROI映射区域坐标
|
||||
DLLEXPORT_API DLL_VOID ROIMappingCoordinateCSharp(Camera_Object_C* camera_obj,int roi_output_size, int *roi_output, PhotoInfoCSharp &target_data, int target_pixel_size, RoiPoint &point_output);
|
||||
//ROI检索映射
|
||||
DLLEXPORT_API DLL_VOID ROIPixelMappingCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &point_data, char *point_pixel, int point_pixel_size, PhotoInfoCSharp &source_data,
|
||||
char *source_data_pixel, int source_pixel_size, PhotoInfoCSharp &target_data, char *target_data_pixel, int target_pixel_size,
|
||||
RoiPoint &roi_input, int ROI_output_size, int *ROI_output);
|
||||
//保存点云 with image to pcd
|
||||
DLLEXPORT_API DLL_INT SavePointCloudWithImageToTxtCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &point_data_info, char *point_pixel, int point_pixel_size,
|
||||
float * rgb_cloud,int rgb_cloud_size, char *path_name);
|
||||
//保存与图片融合后的点云Ply
|
||||
DLLEXPORT_API DLL_INT SavePointCloudWithImageToPlyCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &point_data_info, char *point_pixel, int point_pixel_size,
|
||||
float * rgb_cloud, int rgb_cloud_size, char *path_name);
|
||||
//保存与图片融合后的点云Pcd
|
||||
DLLEXPORT_API DLL_INT SavePointCloudWithImageToPcdCSharp(Camera_Object_C* camera_obj, PhotoInfoCSharp &point_data_info, char *point_pixel, int point_pixel_size,
|
||||
float * rgb_cloud, int rgb_cloud_size, char *path_name);
|
||||
/*C#*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
68
include/gui/PointCloudGLWidget.h
Normal file
68
include/gui/PointCloudGLWidget.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef POINTCLOUDGLWIDGET_H
|
||||
#define POINTCLOUDGLWIDGET_H
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QMatrix4x4>
|
||||
#include <QVector3D>
|
||||
#include <QMouseEvent>
|
||||
#include <QWheelEvent>
|
||||
#include <pcl/point_cloud.h>
|
||||
#include <pcl/point_types.h>
|
||||
#include <vector>
|
||||
|
||||
class PointCloudGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PointCloudGLWidget(QWidget *parent = nullptr);
|
||||
~PointCloudGLWidget();
|
||||
|
||||
void updatePointCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud);
|
||||
|
||||
protected:
|
||||
void initializeGL() override;
|
||||
void resizeGL(int w, int h) override;
|
||||
void paintGL() override;
|
||||
|
||||
// 鼠标交互
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
|
||||
private:
|
||||
void setupShaders();
|
||||
void updateBuffers();
|
||||
|
||||
private:
|
||||
// OpenGL资源
|
||||
QOpenGLShaderProgram *m_program;
|
||||
QOpenGLBuffer *m_vertexBuffer;
|
||||
QOpenGLVertexArrayObject *m_vao;
|
||||
|
||||
// 点云数据
|
||||
std::vector<float> m_vertices;
|
||||
int m_pointCount;
|
||||
|
||||
// 相机参数
|
||||
QMatrix4x4 m_projection;
|
||||
QMatrix4x4 m_view;
|
||||
QMatrix4x4 m_model;
|
||||
|
||||
float m_orthoSize; // 正交投影视野大小(控制缩放)
|
||||
float m_rotationX; // X轴旋转角度
|
||||
float m_rotationY; // Y轴旋转角度
|
||||
QVector3D m_translation; // 平移
|
||||
|
||||
// 鼠标交互状态
|
||||
QPoint m_lastMousePos;
|
||||
bool m_leftButtonPressed;
|
||||
bool m_rightButtonPressed;
|
||||
};
|
||||
|
||||
#endif // POINTCLOUDGLWIDGET_H
|
||||
27
include/gui/PointCloudWidget.h
Normal file
27
include/gui/PointCloudWidget.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef POINTCLOUDWIDGET_H
|
||||
#define POINTCLOUDWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <pcl/point_cloud.h>
|
||||
#include <pcl/point_types.h>
|
||||
|
||||
class PointCloudGLWidget;
|
||||
|
||||
class PointCloudWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PointCloudWidget(QWidget *parent = nullptr);
|
||||
~PointCloudWidget();
|
||||
|
||||
// 更新点云显示
|
||||
void updatePointCloud(pcl::PointCloud<pcl::PointXYZ>::Ptr cloud);
|
||||
|
||||
private:
|
||||
QLabel *m_statusLabel;
|
||||
PointCloudGLWidget *m_glWidget;
|
||||
};
|
||||
|
||||
#endif // POINTCLOUDWIDGET_H
|
||||
Reference in New Issue
Block a user