Files
HPPA/HPPA/RgbCameraOperation.cpp
2026-04-02 10:34:57 +08:00

69 lines
1.3 KiB
C++

#include "stdafx.h"
#include "RgbCameraOperation.h"
RgbCameraOperation::RgbCameraOperation()
{
cam = nullptr;
m_ImageProcessor = new ImageProcessor();
m_func = nullptr;
}
RgbCameraOperation::~RgbCameraOperation()
{
}
void RgbCameraOperation::OpenCamera()
{
std::cout << "打开摄像头+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
cam = new cv::VideoCapture(0);
record = true;
while (record)
{
//std::cout << "采集影像+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
cam->read(frame);
m_qImage = m_ImageProcessor->Mat2QImage(frame);
emit PlotSignal();
}
cam->release();
emit CamClosed();
}
void RgbCameraOperation::OpenCamera_callback()
{
std::cout << "打开摄像头+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
cam = new cv::VideoCapture(0);
record = true;
while (record)
{
//std::cout << "采集影像+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
cam->read(frame);
m_qImage = m_ImageProcessor->Mat2QImage(frame);
if(m_func)
m_func();
}
cam->release();
}
void RgbCameraOperation::setCallback(void(*func)())
{
m_func = func;
}
void RgbCameraOperation::CloseCamera()
{
std::cout << "关闭摄像头+++++++++++++++++++++++++++++++++++++++++++" << std::endl;
record = false;
}