init
This commit is contained in:
85
device/camera/readcameraimagethread.cpp
Normal file
85
device/camera/readcameraimagethread.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
#include "readcameraimagethread.h"
|
||||
|
||||
ReadCameraImageThread::ReadCameraImageThread(QObject *parent)
|
||||
:QThread(parent)
|
||||
{
|
||||
myImage = new QImage();
|
||||
}
|
||||
|
||||
ReadCameraImageThread::~ReadCameraImageThread()
|
||||
{
|
||||
delete myImage;
|
||||
if(NULL == cameraPtr)
|
||||
{
|
||||
delete cameraPtr;
|
||||
}
|
||||
if(NULL == imagePtr)
|
||||
{
|
||||
delete imagePtr;
|
||||
}
|
||||
}
|
||||
|
||||
void ReadCameraImageThread::run()
|
||||
{
|
||||
if(NULL==cameraPtr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(NULL==imagePtr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while(!isInterruptionRequested())
|
||||
{
|
||||
// qDebug()<<"SoftTrigger:"<<cameraPtr->CommandExecute("TriggerSoftware");
|
||||
// qDebug()<<"ReadBuffer:"<<cameraPtr->ReadBuffer(*imagePtr);
|
||||
//cameraPtr->CommandExecute("TriggerSoftware");
|
||||
//cameraPtr->ReadBuffer(*imagePtr);
|
||||
cameraPtr->GetImage(*imagePtr,false);
|
||||
if(isEnableCrossHairLine)
|
||||
{
|
||||
drawCrossHairLine();
|
||||
}
|
||||
|
||||
if(imagePtr->channels()>1)
|
||||
{
|
||||
*myImage = QImage((const unsigned char*)(imagePtr->data),imagePtr->cols,imagePtr->rows,QImage::Format_RGB888);
|
||||
}
|
||||
else
|
||||
{
|
||||
*myImage = QImage((const unsigned char*)(imagePtr->data),imagePtr->cols,imagePtr->rows,QImage::Format_Indexed8);
|
||||
}
|
||||
|
||||
emit messageImageSGL(*myImage);
|
||||
msleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
void ReadCameraImageThread::getCameraPtr(CMvCamera *camera)
|
||||
{
|
||||
cameraPtr = camera;
|
||||
}
|
||||
|
||||
void ReadCameraImageThread::getImagePtr(cv::Mat *image)
|
||||
{
|
||||
imagePtr = image;
|
||||
}
|
||||
|
||||
void ReadCameraImageThread::drawCrossHairLine(Scalar lineColor,int lineWidth)
|
||||
{
|
||||
int heigh = imagePtr->rows;
|
||||
int width = imagePtr->cols;
|
||||
// 水平线
|
||||
Point startPH(0,int(heigh/2)),endPH(int(width),int(heigh/2));
|
||||
line(*imagePtr,startPH,endPH,lineColor,lineWidth);
|
||||
// 垂直线
|
||||
Point startPV(int(width/2),0),endPV(int(width/2),int(heigh));
|
||||
line(*imagePtr,startPV,endPV,lineColor,lineWidth);
|
||||
}
|
||||
|
||||
void ReadCameraImageThread::setEnableCrossHairLine(bool value )
|
||||
{
|
||||
isEnableCrossHairLine = value;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user