forked from floratest1/SpireCV
build done
This commit is contained in:
parent
5d2e5b0250
commit
fe18e3e0b6
|
@ -119,7 +119,8 @@ set(
|
||||||
include/sv_mot.h
|
include/sv_mot.h
|
||||||
include/sv_color_line.h
|
include/sv_color_line.h
|
||||||
include/sv_veri_det.h
|
include/sv_veri_det.h
|
||||||
include/sv_video_input.h
|
# include/sv_video_input.h
|
||||||
|
include/sv_camera.h
|
||||||
include/sv_video_output.h
|
include/sv_video_output.h
|
||||||
include/sv_world.h
|
include/sv_world.h
|
||||||
)
|
)
|
||||||
|
|
|
@ -326,59 +326,59 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum class CameraType {NONE, WEBCAM, V4L2CAM, G1, Q10, MIPI, GX40};
|
// enum class CameraType {NONE, WEBCAM, V4L2CAM, G1, Q10, MIPI, GX40};
|
||||||
|
|
||||||
class CameraBase {
|
// class CameraBase {
|
||||||
public:
|
// public:
|
||||||
CameraBase(CameraType type=CameraType::NONE, int id=0);
|
// CameraBase(CameraType type=CameraType::NONE, int id=0);
|
||||||
~CameraBase();
|
// ~CameraBase();
|
||||||
void open(CameraType type=CameraType::WEBCAM, int id=0);
|
// void open(CameraType type=CameraType::WEBCAM, int id=0);
|
||||||
bool read(cv::Mat& image);
|
// bool read(cv::Mat& image);
|
||||||
void release();
|
// void release();
|
||||||
|
|
||||||
int getW();
|
// int getW();
|
||||||
int getH();
|
// int getH();
|
||||||
int getFps();
|
// int getFps();
|
||||||
std::string getIp();
|
// std::string getIp();
|
||||||
int getPort();
|
// int getPort();
|
||||||
double getBrightness();
|
// double getBrightness();
|
||||||
double getContrast();
|
// double getContrast();
|
||||||
double getSaturation();
|
// double getSaturation();
|
||||||
double getHue();
|
// double getHue();
|
||||||
double getExposure();
|
// double getExposure();
|
||||||
bool isRunning();
|
// bool isRunning();
|
||||||
void setWH(int width, int height);
|
// void setWH(int width, int height);
|
||||||
void setFps(int fps);
|
// void setFps(int fps);
|
||||||
void setIp(std::string ip);
|
// void setIp(std::string ip);
|
||||||
void setPort(int port);
|
// void setPort(int port);
|
||||||
void setBrightness(double brightness);
|
// void setBrightness(double brightness);
|
||||||
void setContrast(double contrast);
|
// void setContrast(double contrast);
|
||||||
void setSaturation(double saturation);
|
// void setSaturation(double saturation);
|
||||||
void setHue(double hue);
|
// void setHue(double hue);
|
||||||
void setExposure(double exposure);
|
// void setExposure(double exposure);
|
||||||
protected:
|
// protected:
|
||||||
virtual void openImpl();
|
// virtual void openImpl();
|
||||||
void _run();
|
// void _run();
|
||||||
|
|
||||||
bool _is_running;
|
// bool _is_running;
|
||||||
bool _is_updated;
|
// bool _is_updated;
|
||||||
std::thread _tt;
|
// std::thread _tt;
|
||||||
cv::VideoCapture _cap;
|
// cv::VideoCapture _cap;
|
||||||
cv::Mat _frame;
|
// cv::Mat _frame;
|
||||||
CameraType _type;
|
// CameraType _type;
|
||||||
int _camera_id;
|
// int _camera_id;
|
||||||
|
|
||||||
int _width;
|
// int _width;
|
||||||
int _height;
|
// int _height;
|
||||||
int _fps;
|
// int _fps;
|
||||||
std::string _ip;
|
// std::string _ip;
|
||||||
int _port;
|
// int _port;
|
||||||
double _brightness;
|
// double _brightness;
|
||||||
double _contrast;
|
// double _contrast;
|
||||||
double _saturation;
|
// double _saturation;
|
||||||
double _hue;
|
// double _hue;
|
||||||
double _exposure;
|
// double _exposure;
|
||||||
};
|
// };
|
||||||
|
|
||||||
|
|
||||||
void drawTargetsInFrame(
|
void drawTargetsInFrame(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#if 0
|
||||||
#ifndef __SV_VIDEO_INPUT__
|
#ifndef __SV_VIDEO_INPUT__
|
||||||
#define __SV_VIDEO_INPUT__
|
#define __SV_VIDEO_INPUT__
|
||||||
|
|
||||||
|
@ -25,3 +26,4 @@ protected:
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
|
@ -39,6 +39,8 @@ the use of this software, even if advised of the possibility of such damage.
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
#include "aruco_samples_utility.hpp"
|
#include "aruco_samples_utility.hpp"
|
||||||
|
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
|
@ -146,10 +148,14 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// VideoCapture inputVideo;
|
// VideoCapture inputVideo;
|
||||||
sv::Camera inputVideo;
|
sv::Camera inputVideo(c_type);
|
||||||
|
inputVideo.setIndex(camId);
|
||||||
|
inputVideo.setStream("192.168.144.64",554);
|
||||||
|
|
||||||
inputVideo.setWH(imW, imH);
|
inputVideo.setWH(imW, imH);
|
||||||
inputVideo.setFps(fps);
|
inputVideo.setFps(fps);
|
||||||
inputVideo.open(c_type, camId);
|
|
||||||
|
inputVideo.open();
|
||||||
|
|
||||||
int waitTime = 10;
|
int waitTime = 10;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -12,10 +13,12 @@ int main(int argc, char *argv[]) {
|
||||||
ad.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
ad.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
||||||
|
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
// cap.setWH(640, 480);
|
|
||||||
|
cap.setIndex(0);
|
||||||
|
cap.setWH(ad.image_width, ad.image_height);
|
||||||
// cap.setFps(30);
|
// cap.setFps(30);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
cap.open(); // CameraID 0
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
int frame_id = 0;
|
int frame_id = 0;
|
||||||
|
|
|
@ -2,15 +2,17 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
|
cap.setIndex(0);
|
||||||
// cap.setWH(640, 480);
|
// cap.setWH(640, 480);
|
||||||
// cap.setFps(30);
|
// cap.setFps(30);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
cap.open(); // CameraID 0
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
while (1)
|
while (1)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace sv;
|
using namespace sv;
|
||||||
|
@ -14,10 +15,11 @@ int main(int argc, char *argv[])
|
||||||
cld.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
cld.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
||||||
|
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
cap.setWH(640, 480);
|
cap.setIndex(0);
|
||||||
|
cap.setWH(cld.image_width, cld.image_height);
|
||||||
// cap.setFps(30);
|
// cap.setFps(30);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
cap.open(); // CameraID 0
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
int frame_id = 0;
|
int frame_id = 0;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -12,10 +13,11 @@ int main(int argc, char *argv[]) {
|
||||||
cod.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
cod.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
||||||
|
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
// cap.setWH(640, 480);
|
cap.setIndex(0);
|
||||||
|
cap.setWH(cod.image_width, cod.image_height);
|
||||||
// cap.setFps(30);
|
// cap.setFps(30);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
cap.open(); // CameraID 0
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
int frame_id = 0;
|
int frame_id = 0;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -48,10 +49,11 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
|
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
// cap.setWH(640, 480);
|
cap.setIndex(0);
|
||||||
|
cap.setWH(cod.image_width, cod.image_height);
|
||||||
// cap.setFps(30);
|
// cap.setFps(30);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
cap.open(); // CameraID 0
|
||||||
|
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -12,10 +13,12 @@ int main(int argc, char *argv[]) {
|
||||||
ed.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
ed.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
||||||
|
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
// cap.setWH(640, 480);
|
cap.setIndex(0);
|
||||||
|
cap.setWH(ed.image_width, ed.image_height);
|
||||||
// cap.setFps(30);
|
// cap.setFps(30);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
cap.open(); // CameraID 0
|
||||||
|
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
int frame_id = 0;
|
int frame_id = 0;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
// 定义窗口名称
|
// 定义窗口名称
|
||||||
static const std::string RGB_WINDOW = "Image window";
|
static const std::string RGB_WINDOW = "Image window";
|
||||||
|
@ -34,27 +35,6 @@ void gimbalNoTrack(void)
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// 实例化吊舱
|
|
||||||
gimbal = new sv::Gimbal(sv::GimbalType::G1, sv::GimbalLink::SERIAL);
|
|
||||||
// 使用 /dev/ttyUSB0 作为控制串口
|
|
||||||
gimbal->setSerialPort("/dev/ttyUSB0");
|
|
||||||
// 以GimableCallback作为状态回调函数启用吊舱控制
|
|
||||||
gimbal->open(GimableCallback);
|
|
||||||
// 定义相机
|
|
||||||
sv::Camera cap;
|
|
||||||
// 设置相机流媒体地址为 192.168.2.64
|
|
||||||
cap.setIp("192.168.2.64");
|
|
||||||
// 设置获取画面分辨率为720P
|
|
||||||
cap.setWH(1280, 720);
|
|
||||||
// 设置视频帧率为30帧
|
|
||||||
cap.setFps(30);
|
|
||||||
// 开启相机
|
|
||||||
cap.open(sv::CameraType::G1);
|
|
||||||
|
|
||||||
// 定义一个新的窗口,可在上面进行框选操作
|
|
||||||
cv::namedWindow(RGB_WINDOW);
|
|
||||||
// 设置窗口操作回调函数,该函数实现整个框选逻辑
|
|
||||||
cv::setMouseCallback(RGB_WINDOW, onMouse, 0);
|
|
||||||
// 实例化 框选目标跟踪类
|
// 实例化 框选目标跟踪类
|
||||||
sv::SingleObjectTracker sot;
|
sv::SingleObjectTracker sot;
|
||||||
// 手动导入相机参数,如果使用Amov的G1等吊舱或相机,则可以忽略该步骤,将自动下载相机参数文件
|
// 手动导入相机参数,如果使用Amov的G1等吊舱或相机,则可以忽略该步骤,将自动下载相机参数文件
|
||||||
|
@ -63,6 +43,37 @@ int main(int argc, char *argv[])
|
||||||
sv::CommonObjectDetector cod;
|
sv::CommonObjectDetector cod;
|
||||||
cod.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_1280x720.yaml");
|
cod.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_1280x720.yaml");
|
||||||
|
|
||||||
|
// 实例化吊舱
|
||||||
|
gimbal = new sv::Gimbal(sv::GimbalType::G1, sv::GimbalLink::SERIAL);
|
||||||
|
// 使用 /dev/ttyUSB0 作为控制串口
|
||||||
|
gimbal->setSerialPort("/dev/ttyUSB0");
|
||||||
|
// 以GimableCallback作为状态回调函数启用吊舱控制
|
||||||
|
gimbal->open(GimableCallback);
|
||||||
|
|
||||||
|
// 打开摄像头
|
||||||
|
sv::Camera cap(sv::CameraType::G1);
|
||||||
|
cap.setStream("192.168.2.64",554);
|
||||||
|
cap.setWH(cod.image_width, cod.image_height);
|
||||||
|
cap.setFps(30);
|
||||||
|
cap.open(); // CameraID 0
|
||||||
|
|
||||||
|
// // 定义相机
|
||||||
|
// sv::Camera cap;
|
||||||
|
// // 设置相机流媒体地址为 192.168.2.64
|
||||||
|
// cap.setIp("192.168.2.64");
|
||||||
|
// // 设置获取画面分辨率为720P
|
||||||
|
// cap.setWH(1280, 720);
|
||||||
|
// // 设置视频帧率为30帧
|
||||||
|
// cap.setFps(30);
|
||||||
|
// // 开启相机
|
||||||
|
// cap.open(sv::CameraType::G1);
|
||||||
|
|
||||||
|
// 定义一个新的窗口,可在上面进行框选操作
|
||||||
|
cv::namedWindow(RGB_WINDOW);
|
||||||
|
// 设置窗口操作回调函数,该函数实现整个框选逻辑
|
||||||
|
cv::setMouseCallback(RGB_WINDOW, onMouse, 0);
|
||||||
|
|
||||||
|
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
int frame_id = 0;
|
int frame_id = 0;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
// #include "gimbal_tools.hpp"
|
// #include "gimbal_tools.hpp"
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -33,32 +34,40 @@ void gimbalNoTrack(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
// 实例化 圆形降落标志 检测器类
|
||||||
|
sv::LandingMarkerDetector lmd;
|
||||||
|
// 手动导入相机参数,如果使用Amov的G1等吊舱或相机,则可以忽略该步骤,将自动下载相机参数文件
|
||||||
|
lmd.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_1280x720.yaml");
|
||||||
// 实例化吊舱
|
// 实例化吊舱
|
||||||
gimbal = new sv::Gimbal(sv::GimbalType::G1, sv::GimbalLink::SERIAL);
|
gimbal = new sv::Gimbal(sv::GimbalType::G1, sv::GimbalLink::SERIAL);
|
||||||
// 使用 /dev/ttyUSB0 作为控制串口
|
// 使用 /dev/ttyUSB0 作为控制串口
|
||||||
gimbal->setSerialPort("/dev/ttyUSB0");
|
gimbal->setSerialPort("/dev/ttyUSB0");
|
||||||
// 以GimableCallback作为状态回调函数启用吊舱控制
|
// 以GimableCallback作为状态回调函数启用吊舱控制
|
||||||
gimbal->open(GimableCallback);
|
gimbal->open(GimableCallback);
|
||||||
// 定义相机
|
|
||||||
sv::Camera cap;
|
// 打开摄像头
|
||||||
// 设置相机流媒体地址为 192.168.2.64
|
sv::Camera cap(sv::CameraType::G1);
|
||||||
cap.setIp("192.168.2.64");
|
cap.setStream("192.168.2.64", 554);
|
||||||
// 设置获取画面分辨率为720P
|
cap.setWH(lmd.image_width, lmd.image_height);
|
||||||
cap.setWH(1280, 720);
|
|
||||||
// 设置视频帧率为30帧
|
|
||||||
cap.setFps(30);
|
cap.setFps(30);
|
||||||
// 开启相机
|
cap.open(); // CameraID 0
|
||||||
cap.open(sv::CameraType::G1);
|
|
||||||
|
// // 定义相机
|
||||||
|
// sv::Camera cap;
|
||||||
|
// // 设置相机流媒体地址为 192.168.2.64
|
||||||
|
// cap.setIp("192.168.2.64");
|
||||||
|
// // 设置获取画面分辨率为720P
|
||||||
|
// cap.setWH(1280, 720);
|
||||||
|
// // 设置视频帧率为30帧
|
||||||
|
// cap.setFps(30);
|
||||||
|
// // 开启相机
|
||||||
|
// cap.open(sv::CameraType::G1);
|
||||||
|
|
||||||
// 定义一个窗口 才可以在上面操作
|
// 定义一个窗口 才可以在上面操作
|
||||||
cv::namedWindow(RGB_WINDOW);
|
cv::namedWindow(RGB_WINDOW);
|
||||||
// 设置窗口操作回调函数,该函数实现吊舱控制
|
// 设置窗口操作回调函数,该函数实现吊舱控制
|
||||||
cv::setMouseCallback(RGB_WINDOW, onMouse, 0);
|
cv::setMouseCallback(RGB_WINDOW, onMouse, 0);
|
||||||
// 实例化 圆形降落标志 检测器类
|
|
||||||
sv::LandingMarkerDetector lmd;
|
|
||||||
// 手动导入相机参数,如果使用Amov的G1等吊舱或相机,则可以忽略该步骤,将自动下载相机参数文件
|
|
||||||
lmd.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_1280x720.yaml");
|
|
||||||
|
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -42,32 +43,41 @@ static const std::string RGB_WINDOW = "Image window";
|
||||||
void onMouse(int event, int x, int y, int, void *);
|
void onMouse(int event, int x, int y, int, void *);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
// 实例化Aruco检测器类
|
||||||
|
sv::ArucoDetector ad;
|
||||||
|
// 手动导入相机参数,如果使用Amov的G1等吊舱或相机,则可以忽略该步骤,将自动下载相机参数文件
|
||||||
|
ad.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_1280x720.yaml");
|
||||||
// 实例化吊舱
|
// 实例化吊舱
|
||||||
gimbal = new sv::Gimbal(sv::GimbalType::G1, sv::GimbalLink::SERIAL);
|
gimbal = new sv::Gimbal(sv::GimbalType::G1, sv::GimbalLink::SERIAL);
|
||||||
// 使用 /dev/ttyUSB0 作为控制串口
|
// 使用 /dev/ttyUSB0 作为控制串口
|
||||||
gimbal->setSerialPort("/dev/ttyUSB0");
|
gimbal->setSerialPort("/dev/ttyUSB0");
|
||||||
// 以gimableCallback作为状态回调函数启用吊舱控制
|
// 以gimableCallback作为状态回调函数启用吊舱控制
|
||||||
gimbal->open(gimableCallback);
|
gimbal->open(gimableCallback);
|
||||||
// 定义相机
|
|
||||||
sv::Camera cap;
|
// 打开摄像头
|
||||||
// 设置相机流媒体地址为 192.168.2.64
|
sv::Camera cap(sv::CameraType::G1);
|
||||||
cap.setIp("192.168.2.64");
|
cap.setStream("192.168.2.64",554);
|
||||||
// 设置获取画面分辨率为720P
|
cap.setWH(ad.image_width, ad.image_height);
|
||||||
cap.setWH(1280, 720);
|
|
||||||
// 设置视频帧率为30帧
|
|
||||||
cap.setFps(30);
|
cap.setFps(30);
|
||||||
// 开启相机
|
cap.open(); // CameraID 0
|
||||||
cap.open(sv::CameraType::G1);
|
|
||||||
|
// // 定义相机
|
||||||
|
// sv::Camera cap;
|
||||||
|
// // 设置相机流媒体地址为 192.168.2.64
|
||||||
|
// cap.setIp("192.168.2.64");
|
||||||
|
// // 设置获取画面分辨率为720P
|
||||||
|
// cap.setWH(1280, 720);
|
||||||
|
// // 设置视频帧率为30帧
|
||||||
|
// cap.setFps(30);
|
||||||
|
// // 开启相机
|
||||||
|
// cap.open(sv::CameraType::G1);
|
||||||
|
|
||||||
// 定义一个窗口 才可以在上面操作
|
// 定义一个窗口 才可以在上面操作
|
||||||
cv::namedWindow(RGB_WINDOW);
|
cv::namedWindow(RGB_WINDOW);
|
||||||
// 设置窗口操作回调函数,该函数实现吊舱控制
|
// 设置窗口操作回调函数,该函数实现吊舱控制
|
||||||
cv::setMouseCallback(RGB_WINDOW, onMouse, 0);
|
cv::setMouseCallback(RGB_WINDOW, onMouse, 0);
|
||||||
// 实例化Aruco检测器类
|
|
||||||
sv::ArucoDetector ad;
|
|
||||||
// 手动导入相机参数,如果使用Amov的G1等吊舱或相机,则可以忽略该步骤,将自动下载相机参数文件
|
|
||||||
ad.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_1280x720.yaml");
|
|
||||||
|
|
||||||
sv::UDPServer udp;
|
sv::UDPServer udp;
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
@ -11,11 +11,13 @@ int main(int argc, char *argv[]) {
|
||||||
// 手动导入相机参数,如果使用Amov的G1等吊舱或相机,则可以忽略该步骤,将自动下载相机参数文件
|
// 手动导入相机参数,如果使用Amov的G1等吊舱或相机,则可以忽略该步骤,将自动下载相机参数文件
|
||||||
lmd.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
lmd.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
||||||
|
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
// cap.setWH(640, 480);
|
cap.setIndex(0);
|
||||||
|
cap.setWH(lmd.image_width, lmd.image_height);
|
||||||
// cap.setFps(30);
|
// cap.setFps(30);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
cap.open(); // CameraID 0
|
||||||
|
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
int frame_id = 0;
|
int frame_id = 0;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -15,11 +16,13 @@ int main(int argc, char *argv[]) {
|
||||||
mot.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
mot.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
||||||
mot.init(&cod);
|
mot.init(&cod);
|
||||||
|
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
// cap.setWH(640, 480);
|
cap.setIndex(0);
|
||||||
|
cap.setWH(cod.image_width, cod.image_height);
|
||||||
// cap.setFps(30);
|
// cap.setFps(30);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
cap.open(); // CameraID 0
|
||||||
|
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
int frame_id = 0;
|
int frame_id = 0;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// 定义窗口名称
|
// 定义窗口名称
|
||||||
|
@ -32,11 +32,13 @@ int main(int argc, char *argv[]) {
|
||||||
// sot.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_1280x720.yaml");
|
// sot.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_1280x720.yaml");
|
||||||
// sot.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_1920x1080.yaml");
|
// sot.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_1920x1080.yaml");
|
||||||
|
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
// cap.setWH(640, 480);
|
cap.setIndex(0);
|
||||||
|
cap.setWH(sot.image_width, sot.image_height);
|
||||||
// cap.setFps(30);
|
// cap.setFps(30);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
cap.open(); // CameraID 0
|
||||||
|
|
||||||
// cv::VideoCapture cap("/home/amov/SpireCV/test/tracking_1280x720.mp4");
|
// cv::VideoCapture cap("/home/amov/SpireCV/test/tracking_1280x720.mp4");
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
@ -11,11 +11,12 @@ int main(int argc, char *argv[]) {
|
||||||
// 手动导入相机参数,如果使用Amov的G1等吊舱或相机,则可以忽略该步骤,将自动下载相机参数文件
|
// 手动导入相机参数,如果使用Amov的G1等吊舱或相机,则可以忽略该步骤,将自动下载相机参数文件
|
||||||
ad.loadCameraParams("/home/amov/SpireCV/calib_webcam_640x480.yaml");
|
ad.loadCameraParams("/home/amov/SpireCV/calib_webcam_640x480.yaml");
|
||||||
|
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
cap.setWH(640, 480);
|
cap.setIndex(0);
|
||||||
cap.setFps(30);
|
cap.setWH(ad.image_width, ad.image_height);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
// cap.setFps(30);
|
||||||
|
cap.open(); // CameraID 0
|
||||||
|
|
||||||
sv::UDPServer udp;
|
sv::UDPServer udp;
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
struct node
|
struct node
|
||||||
|
@ -25,11 +25,12 @@ int main(int argc, char *argv[])
|
||||||
sv::CommonObjectDetector cod;
|
sv::CommonObjectDetector cod;
|
||||||
cod.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
cod.loadCameraParams(sv::get_home() + "/SpireCV/calib_webcam_640x480.yaml");
|
||||||
|
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
// cap.setWH(640, 480);
|
cap.setIndex(0);
|
||||||
|
cap.setWH(cod.image_width, cod.image_height);
|
||||||
// cap.setFps(30);
|
// cap.setFps(30);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
cap.open(); // CameraID 0
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
int frame_id = 0;
|
int frame_id = 0;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
@ -12,10 +12,12 @@ int main(int argc, char *argv[]) {
|
||||||
cod.loadCameraParams("/home/amov/SpireCV/calib_webcam_640x480.yaml");
|
cod.loadCameraParams("/home/amov/SpireCV/calib_webcam_640x480.yaml");
|
||||||
|
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
// 打开摄像头
|
||||||
// cap.setWH(640, 480);
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
|
cap.setIndex(0);
|
||||||
|
cap.setWH(cod.image_width, cod.image_height);
|
||||||
// cap.setFps(30);
|
// cap.setFps(30);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
cap.open(); // CameraID 0
|
||||||
// 实例化OpenCV的Mat类,用于内存单帧图像
|
// 实例化OpenCV的Mat类,用于内存单帧图像
|
||||||
cv::Mat img;
|
cv::Mat img;
|
||||||
int frame_id = 0;
|
int frame_id = 0;
|
||||||
|
|
|
@ -2,15 +2,17 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
// 打开摄像头
|
// 打开摄像头
|
||||||
sv::Camera cap;
|
sv::Camera cap(sv::CameraType::WEBCAM);
|
||||||
// cap.setWH(1280, 720);
|
cap.setIndex(0);
|
||||||
// cap.setFps(30);
|
cap.setWH(1280, 720);
|
||||||
cap.open(sv::CameraType::WEBCAM, 0); // CameraID 0
|
cap.setFps(30);
|
||||||
|
cap.open(); // CameraID 0
|
||||||
|
|
||||||
// 实例化视频推流类sv::VideoStreamer
|
// 实例化视频推流类sv::VideoStreamer
|
||||||
sv::VideoStreamer streamer;
|
sv::VideoStreamer streamer;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// 包含SpireCV SDK头文件
|
// 包含SpireCV SDK头文件
|
||||||
#include <sv_world.h>
|
#include <sv_world.h>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include "sv_camera.h"
|
||||||
|
|
||||||
// yaw roll pitch
|
// yaw roll pitch
|
||||||
double gimbalEulerAngle[3];
|
double gimbalEulerAngle[3];
|
||||||
|
@ -143,14 +144,20 @@ int main(int argc, char *argv[])
|
||||||
std::cout << " pass... " << std::endl;
|
std::cout << " pass... " << std::endl;
|
||||||
std::cout << " start image test " << std::endl;
|
std::cout << " start image test " << std::endl;
|
||||||
|
|
||||||
sv::Camera cap;
|
// 打开摄像头
|
||||||
cap.setIp(argv[2]);
|
sv::Camera cap(sv::CameraType::G1);
|
||||||
|
cap.setStream(argv[2], 554);
|
||||||
cap.setWH(1280, 720);
|
cap.setWH(1280, 720);
|
||||||
cap.setFps(30);
|
cap.setFps(30);
|
||||||
|
cap.open(); // CameraID 0
|
||||||
|
|
||||||
cap.open(sv::CameraType::G1);
|
// sv::Camera cap;
|
||||||
|
// cap.setIp(argv[2]);
|
||||||
|
// cap.setWH(1280, 720);
|
||||||
|
// cap.setFps(30);
|
||||||
|
// cap.open(sv::CameraType::G1);
|
||||||
|
|
||||||
if (!cap.isRunning())
|
if (!cap.isActive())
|
||||||
{
|
{
|
||||||
std::cout << " gimbal image error , failed !!!!!" << std::endl;
|
std::cout << " gimbal image error , failed !!!!!" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* @Description: G1相机的具体功能实现
|
* @Description:
|
||||||
* @Author: L LC @amov
|
* @Author: L LC @amov
|
||||||
* @Date: 2023-12-19 18:30:17
|
* @Date: 2023-12-19 18:30:17
|
||||||
* @LastEditors: L LC @amov
|
* @LastEditors: L LC @amov
|
||||||
* @LastEditTime: 2023-12-21 11:42:40
|
* @LastEditTime: 2023-12-21 17:56:47
|
||||||
* @FilePath: /SpireCV/video_io/driver/sv_camera_G1.cpp
|
* @FilePath: /SpireCV/video_io/driver/sv_camera_G1.cpp
|
||||||
*/
|
*/
|
||||||
#include "../sv_camera_privately.h"
|
#include "sv_camera_privately.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
class sv_camera_G1 : public sv_p::CameraBase
|
class sv_camera_G1 : public sv_p::CameraBase
|
||||||
|
@ -44,13 +44,6 @@ bool sv_camera_G1::setStream(const std::string &ip, uint16_t port)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 合法的输入尺寸列表
|
|
||||||
const static std::vector<uint32_t, uint32_t> imageSizeList[3] =
|
|
||||||
{
|
|
||||||
{1520, 2704},
|
|
||||||
{1080, 1920},
|
|
||||||
{720, 1280}};
|
|
||||||
|
|
||||||
const static uint32_t imageHList[3] = {1520, 1080, 720};
|
const static uint32_t imageHList[3] = {1520, 1080, 720};
|
||||||
const static uint32_t imageWList[3] = {2704, 1920, 1280};
|
const static uint32_t imageWList[3] = {2704, 1920, 1280};
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
* @Author: L LC @amov
|
* @Author: L LC @amov
|
||||||
* @Date: 2023-12-19 18:30:17
|
* @Date: 2023-12-19 18:30:17
|
||||||
* @LastEditors: L LC @amov
|
* @LastEditors: L LC @amov
|
||||||
* @LastEditTime: 2023-12-21 17:27:22
|
* @LastEditTime: 2023-12-21 17:57:02
|
||||||
* @FilePath: /SpireCV/video_io/driver/sv_camera_GX40.cpp
|
* @FilePath: /SpireCV/video_io/driver/sv_camera_GX40.cpp
|
||||||
*/
|
*/
|
||||||
#include "../sv_camera_privately.h"
|
#include "sv_camera_privately.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
class sv_camera_GX40 : public sv_p::CameraBase
|
class sv_camera_GX40 : public sv_p::CameraBase
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
* @Author: L LC @amov
|
* @Author: L LC @amov
|
||||||
* @Date: 2023-12-19 18:30:17
|
* @Date: 2023-12-19 18:30:17
|
||||||
* @LastEditors: L LC @amov
|
* @LastEditors: L LC @amov
|
||||||
* @LastEditTime: 2023-12-21 17:10:30
|
* @LastEditTime: 2023-12-21 17:57:07
|
||||||
* @FilePath: /SpireCV/video_io/driver/sv_camera_MC1.cpp
|
* @FilePath: /SpireCV/video_io/driver/sv_camera_MC1.cpp
|
||||||
*/
|
*/
|
||||||
#include "../sv_camera_privately.h"
|
#include "sv_camera_privately.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
class sv_camera_MC1 : public sv_p::CameraBase
|
class sv_camera_MC1 : public sv_p::CameraBase
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
* @Author: L LC @amov
|
* @Author: L LC @amov
|
||||||
* @Date: 2023-12-21 10:45:50
|
* @Date: 2023-12-21 10:45:50
|
||||||
* @LastEditors: L LC @amov
|
* @LastEditors: L LC @amov
|
||||||
* @LastEditTime: 2023-12-21 11:26:43
|
* @LastEditTime: 2023-12-21 17:57:30
|
||||||
* @FilePath: /SpireCV/video_io/driver/sv_camera_V4L2s.cpp
|
* @FilePath: /SpireCV/video_io/driver/sv_camera_V4L2s.cpp
|
||||||
*/
|
*/
|
||||||
#include "../sv_camera_privately.h"
|
#include "sv_camera_privately.h"
|
||||||
|
|
||||||
class sv_camera_V4L2 : public sv_p::CameraBase
|
class sv_camera_V4L2 : public sv_p::CameraBase
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
* @Author: L LC @amov
|
* @Author: L LC @amov
|
||||||
* @Date: 2023-12-21 11:30:40
|
* @Date: 2023-12-21 11:30:40
|
||||||
* @LastEditors: L LC @amov
|
* @LastEditors: L LC @amov
|
||||||
* @LastEditTime: 2023-12-21 11:43:08
|
* @LastEditTime: 2023-12-21 17:56:34
|
||||||
* @FilePath: /SpireCV/video_io/driver/sv_camera_file.cpp
|
* @FilePath: /SpireCV/video_io/driver/sv_camera_file.cpp
|
||||||
*/
|
*/
|
||||||
#include "../sv_camera_privately.h"
|
#include "sv_camera_privately.h"
|
||||||
|
|
||||||
class sv_camera_FILE : public sv_p::CameraBase
|
class sv_camera_FILE : public sv_p::CameraBase
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* @Description: G1相机的具体功能实现
|
* @Description:
|
||||||
* @Author: L LC @amov
|
* @Author: L LC @amov
|
||||||
* @Date: 2023-12-19 18:30:17
|
* @Date: 2023-12-19 18:30:17
|
||||||
* @LastEditors: L LC @amov
|
* @LastEditors: L LC @amov
|
||||||
* @LastEditTime: 2023-12-21 14:40:30
|
* @LastEditTime: 2023-12-21 17:57:12
|
||||||
* @FilePath: /SpireCV/video_io/driver/sv_camera_mipi.cpp
|
* @FilePath: /SpireCV/video_io/driver/sv_camera_mipi.cpp
|
||||||
*/
|
*/
|
||||||
#include "../sv_camera_privately.h"
|
#include "sv_camera_privately.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
class sv_camera_MIPI : public sv_p::CameraBase
|
class sv_camera_MIPI : public sv_p::CameraBase
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
* @Author: L LC @amov
|
* @Author: L LC @amov
|
||||||
* @Date: 2023-12-21 11:30:40
|
* @Date: 2023-12-21 11:30:40
|
||||||
* @LastEditors: L LC @amov
|
* @LastEditors: L LC @amov
|
||||||
* @LastEditTime: 2023-12-21 11:43:16
|
* @LastEditTime: 2023-12-21 17:57:22
|
||||||
* @FilePath: /SpireCV/video_io/driver/sv_camera_streaming.cpp
|
* @FilePath: /SpireCV/video_io/driver/sv_camera_streaming.cpp
|
||||||
*/
|
*/
|
||||||
#include "../sv_camera_privately.h"
|
#include "sv_camera_privately.h"
|
||||||
|
|
||||||
class sv_camera_Streaming : public sv_p::CameraBase
|
class sv_camera_Streaming : public sv_p::CameraBase
|
||||||
{
|
{
|
||||||
|
|
|
@ -969,172 +969,172 @@ void VideoWriterBase::releaseImpl()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CameraBase::CameraBase(CameraType type, int id)
|
// CameraBase::CameraBase(CameraType type, int id)
|
||||||
{
|
// {
|
||||||
this->_is_running = false;
|
// this->_is_running = false;
|
||||||
this->_is_updated = false;
|
// this->_is_updated = false;
|
||||||
this->_type = type;
|
// this->_type = type;
|
||||||
|
|
||||||
this->_width = -1;
|
// this->_width = -1;
|
||||||
this->_height = -1;
|
// this->_height = -1;
|
||||||
this->_fps = -1;
|
// this->_fps = -1;
|
||||||
this->_ip = "192.168.2.64";
|
// this->_ip = "192.168.2.64";
|
||||||
this->_port = -1;
|
// this->_port = -1;
|
||||||
this->_brightness = -1;
|
// this->_brightness = -1;
|
||||||
this->_contrast = -1;
|
// this->_contrast = -1;
|
||||||
this->_saturation = -1;
|
// this->_saturation = -1;
|
||||||
this->_hue = -1;
|
// this->_hue = -1;
|
||||||
this->_exposure = -1;
|
// this->_exposure = -1;
|
||||||
|
|
||||||
this->open(type, id);
|
// this->open(type, id);
|
||||||
}
|
// }
|
||||||
CameraBase::~CameraBase()
|
// CameraBase::~CameraBase()
|
||||||
{
|
// {
|
||||||
this->_is_running = false;
|
// this->_is_running = false;
|
||||||
// this->_tt.join();
|
// // this->_tt.join();
|
||||||
}
|
// }
|
||||||
void CameraBase::setWH(int width, int height)
|
// void CameraBase::setWH(int width, int height)
|
||||||
{
|
// {
|
||||||
this->_width = width;
|
// this->_width = width;
|
||||||
this->_height = height;
|
// this->_height = height;
|
||||||
}
|
// }
|
||||||
void CameraBase::setFps(int fps)
|
// void CameraBase::setFps(int fps)
|
||||||
{
|
// {
|
||||||
this->_fps = fps;
|
// this->_fps = fps;
|
||||||
}
|
// }
|
||||||
void CameraBase::setIp(std::string ip)
|
// void CameraBase::setIp(std::string ip)
|
||||||
{
|
// {
|
||||||
this->_ip = ip;
|
// this->_ip = ip;
|
||||||
}
|
// }
|
||||||
void CameraBase::setPort(int port)
|
// void CameraBase::setPort(int port)
|
||||||
{
|
// {
|
||||||
this->_port = port;
|
// this->_port = port;
|
||||||
}
|
// }
|
||||||
void CameraBase::setBrightness(double brightness)
|
// void CameraBase::setBrightness(double brightness)
|
||||||
{
|
// {
|
||||||
this->_brightness = brightness;
|
// this->_brightness = brightness;
|
||||||
}
|
// }
|
||||||
void CameraBase::setContrast(double contrast)
|
// void CameraBase::setContrast(double contrast)
|
||||||
{
|
// {
|
||||||
this->_contrast = contrast;
|
// this->_contrast = contrast;
|
||||||
}
|
// }
|
||||||
void CameraBase::setSaturation(double saturation)
|
// void CameraBase::setSaturation(double saturation)
|
||||||
{
|
// {
|
||||||
this->_saturation = saturation;
|
// this->_saturation = saturation;
|
||||||
}
|
// }
|
||||||
void CameraBase::setHue(double hue)
|
// void CameraBase::setHue(double hue)
|
||||||
{
|
// {
|
||||||
this->_hue = hue;
|
// this->_hue = hue;
|
||||||
}
|
// }
|
||||||
void CameraBase::setExposure(double exposure)
|
// void CameraBase::setExposure(double exposure)
|
||||||
{
|
// {
|
||||||
this->_exposure = exposure;
|
// this->_exposure = exposure;
|
||||||
}
|
// }
|
||||||
|
|
||||||
int CameraBase::getW()
|
// int CameraBase::getW()
|
||||||
{
|
// {
|
||||||
return this->_width;
|
// return this->_width;
|
||||||
}
|
// }
|
||||||
int CameraBase::getH()
|
// int CameraBase::getH()
|
||||||
{
|
// {
|
||||||
return this->_height;
|
// return this->_height;
|
||||||
}
|
// }
|
||||||
int CameraBase::getFps()
|
// int CameraBase::getFps()
|
||||||
{
|
// {
|
||||||
return this->_fps;
|
// return this->_fps;
|
||||||
}
|
// }
|
||||||
std::string CameraBase::getIp()
|
// std::string CameraBase::getIp()
|
||||||
{
|
// {
|
||||||
return this->_ip;
|
// return this->_ip;
|
||||||
}
|
// }
|
||||||
int CameraBase::getPort()
|
// int CameraBase::getPort()
|
||||||
{
|
// {
|
||||||
return this->_port;
|
// return this->_port;
|
||||||
}
|
// }
|
||||||
double CameraBase::getBrightness()
|
// double CameraBase::getBrightness()
|
||||||
{
|
// {
|
||||||
return this->_brightness;
|
// return this->_brightness;
|
||||||
}
|
// }
|
||||||
double CameraBase::getContrast()
|
// double CameraBase::getContrast()
|
||||||
{
|
// {
|
||||||
return this->_contrast;
|
// return this->_contrast;
|
||||||
}
|
// }
|
||||||
double CameraBase::getSaturation()
|
// double CameraBase::getSaturation()
|
||||||
{
|
// {
|
||||||
return this->_saturation;
|
// return this->_saturation;
|
||||||
}
|
// }
|
||||||
double CameraBase::getHue()
|
// double CameraBase::getHue()
|
||||||
{
|
// {
|
||||||
return this->_hue;
|
// return this->_hue;
|
||||||
}
|
// }
|
||||||
double CameraBase::getExposure()
|
// double CameraBase::getExposure()
|
||||||
{
|
// {
|
||||||
return this->_exposure;
|
// return this->_exposure;
|
||||||
}
|
// }
|
||||||
bool CameraBase::isRunning()
|
// bool CameraBase::isRunning()
|
||||||
{
|
// {
|
||||||
return this->_is_running;
|
// return this->_is_running;
|
||||||
}
|
// }
|
||||||
|
|
||||||
void CameraBase::openImpl()
|
// void CameraBase::openImpl()
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
// }
|
||||||
void CameraBase::open(CameraType type, int id)
|
// void CameraBase::open(CameraType type, int id)
|
||||||
{
|
// {
|
||||||
this->_type = type;
|
// this->_type = type;
|
||||||
this->_camera_id = id;
|
// this->_camera_id = id;
|
||||||
|
|
||||||
openImpl();
|
// openImpl();
|
||||||
|
|
||||||
if (this->_cap.isOpened())
|
// if (this->_cap.isOpened())
|
||||||
{
|
// {
|
||||||
std::cout << "Camera opened!" << std::endl;
|
// std::cout << "Camera opened!" << std::endl;
|
||||||
this->_is_running = true;
|
// this->_is_running = true;
|
||||||
this->_tt = std::thread(&CameraBase::_run, this);
|
// this->_tt = std::thread(&CameraBase::_run, this);
|
||||||
this->_tt.detach();
|
// this->_tt.detach();
|
||||||
}
|
// }
|
||||||
else if (type != CameraType::NONE)
|
// else if (type != CameraType::NONE)
|
||||||
{
|
// {
|
||||||
std::cout << "Camera can NOT open!" << std::endl;
|
// std::cout << "Camera can NOT open!" << std::endl;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
void CameraBase::_run()
|
// void CameraBase::_run()
|
||||||
{
|
// {
|
||||||
while (this->_is_running && this->_cap.isOpened())
|
// while (this->_is_running && this->_cap.isOpened())
|
||||||
{
|
// {
|
||||||
this->_cap >> this->_frame;
|
// this->_cap >> this->_frame;
|
||||||
this->_is_updated = true;
|
// this->_is_updated = true;
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(2));
|
// std::this_thread::sleep_for(std::chrono::milliseconds(2));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
bool CameraBase::read(cv::Mat& image)
|
// bool CameraBase::read(cv::Mat& image)
|
||||||
{
|
// {
|
||||||
if (this->_type != CameraType::NONE)
|
// if (this->_type != CameraType::NONE)
|
||||||
{
|
// {
|
||||||
int n_try = 0;
|
// int n_try = 0;
|
||||||
while (n_try < 5000)
|
// while (n_try < 5000)
|
||||||
{
|
// {
|
||||||
if (this->_is_updated)
|
// if (this->_is_updated)
|
||||||
{
|
// {
|
||||||
this->_is_updated = false;
|
// this->_is_updated = false;
|
||||||
this->_frame.copyTo(image);
|
// this->_frame.copyTo(image);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
// std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||||
n_try ++;
|
// n_try ++;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (image.cols == 0 || image.rows == 0)
|
// if (image.cols == 0 || image.rows == 0)
|
||||||
{
|
// {
|
||||||
throw std::runtime_error("SpireCV (101) Camera cannot OPEN, check CAMERA_ID!");
|
// throw std::runtime_error("SpireCV (101) Camera cannot OPEN, check CAMERA_ID!");
|
||||||
}
|
// }
|
||||||
return image.cols > 0 && image.rows > 0;
|
// return image.cols > 0 && image.rows > 0;
|
||||||
}
|
// }
|
||||||
void CameraBase::release()
|
// void CameraBase::release()
|
||||||
{
|
// {
|
||||||
_cap.release();
|
// _cap.release();
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#if 0
|
||||||
#include "sv_video_input.h"
|
#include "sv_video_input.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -130,3 +131,5 @@ void Camera::openImpl()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue