服务器之家

服务器之家 > 正文

Qt(C++)调用工业相机Basler的SDK使用示例

时间:2021-08-21 16:58     来源/作者:沙振宇

简介

由于公司采购的AVT相机不足,需要用Basler相机来弥补,所以我也了解了一下Basler这款相机的SDK。由于Basler这边的相机提供的没有提供Qt的示例,所以我做一个分享出来。

本篇的Demo采用的是工业黑白相机。工业应用中,如果我们要处理的是与图像颜色有关,那么我们最好采用彩色工业相机;如果不是,那么我们最好选用黑白工业相机,因为在同样分辨率下的工业相机,黑白工业教学精度比彩色工业相机高,尤其是在看图像边缘的时候,黑白工业相机的效果更好。

开发环境

  • Qt:  5.6.2vc2013版
  • Basler:  5.0.11版

效果图

Qt(C++)调用工业相机Basler的SDK使用示例

上图只是做了SDK部分接口的获取和设置。相机的触发方式、曝光时间、增益、频率,以及图片的尺寸、灯的触发信号等。

Basler相机SDK接口调用控制类

  1. #ifndef SBASLERCAMERACONTROL_H
  2. #define SBASLERCAMERACONTROL_H
  3.  
  4. #include <QObject>
  5. #include <pylon/PylonIncludes.h>
  6. #include <QImage>
  7. #include <QTimer>
  8.  
  9. #define DOUBLE_MAX 100000
  10. #define DOUBLE_MIN 0
  11.  
  12. using namespace std;
  13. using namespace Pylon;
  14. using namespace GenApi;
  15. class SBaslerCameraControl : public QObject
  16. {
  17. Q_OBJECT
  18. public:
  19. explicit SBaslerCameraControl(QObject *parent = 0);
  20. ~SBaslerCameraControl();
  21.  
  22. enum SBaslerCameraControl_Type{
  23. Type_Basler_Freerun, //设置相机的内触发
  24. Type_Basler_Line1, //设置相机的外触发
  25. Type_Basler_ExposureTimeAbs, //设置相机的曝光时间
  26. Type_Basler_GainRaw, //设置相机的增益
  27. Type_Basler_AcquisitionFrameRateAbs, //设置相机的频率
  28. Type_Basler_Width, //图片的宽度
  29. Type_Basler_Height, //图片的高度
  30. Type_Basler_LineSource, //灯的触发信号
  31. };
  32. void initSome();
  33. void deleteAll();
  34. QStringList cameras();
  35. int OpenCamera(QString cameraSN);
  36. int CloseCamera();
  37.  
  38. void setExposureTime(double time); // 设置曝光时间
  39. int getExposureTime(); // 获取曝光时间
  40. int getExposureTimeMin(); // 最小曝光时间
  41. int getExposureTimeMax(); // 最大曝光时间
  42.  
  43. void setFeatureTriggerSourceType(QString type); // 设置种类
  44. QString getFeatureTriggerSourceType(); // 获取种类:软触发、外触发等等
  45.  
  46. void setFeatureTriggerModeType(bool on); // 设置模式触发
  47. bool getFeatureTriggerModeType(); // 获取模式触发
  48. void SetCamera(SBaslerCameraControl::SBaslerCameraControl_Type index, double tmpValue = 0.0); // 设置各种参数
  49. double GetCamera(SBaslerCameraControl::SBaslerCameraControl_Type index); // 获取各种参数
  50.  
  51. long GrabImage(QImage& image,int timeout = 2000);
  52. long StartAcquire(); // 开始采集
  53. long StopAcquire(); // 结束采集
  54. signals:
  55. void sigCameraUpdate(QStringList list);
  56. void sigSizeChange(QSize size);
  57. void sigCameraCount(int count);
  58. void sigCurrentImage(QImage img);
  59. private:
  60. void UpdateCameraList();
  61. void CopyToImage(CGrabResultPtr pInBuffer, QImage &OutImage);
  62. private slots:
  63. void onTimerGrabImage();
  64. private:
  65. CInstantCamera m_basler;
  66. QStringList m_cameralist;
  67. QString m_currentMode;
  68. bool m_isOpenAcquire = false; // 是否开始采集
  69. bool m_isOpen = false; // 是否打开摄像头
  70. QSize m_size;
  71. };
  72.  
  73. #endif // SBASLERCAMERACONTROL_H

源文件:

  1. #include "sbaslercameracontrol.h"
  2. #include <QDateTime>
  3. #include <QDebug>
  4.  
  5. SBaslerCameraControl::SBaslerCameraControl(QObject *parent) : QObject(parent)
  6. {
  7. }
  8.  
  9. SBaslerCameraControl::~SBaslerCameraControl()
  10. {
  11. }
  12.  
  13. void SBaslerCameraControl::initSome()
  14. {
  15. qDebug() << "SBaslerCameraControl: PylonInitialize initSome" ;
  16. PylonInitialize();
  17. CTlFactory &TlFactory = CTlFactory::GetInstance();
  18. TlInfoList_t lstInfo;
  19. int n = TlFactory.EnumerateTls(lstInfo);
  20.  
  21. TlInfoList_t::const_iterator it;
  22. for ( it = lstInfo.begin(); it != lstInfo.end(); ++it ) {
  23. qDebug() << "FriendlyName: " << it->GetFriendlyName() << "FullName: " << it->GetFullName();
  24. qDebug() << "VendorName: " << it->GetVendorName() << "DeviceClass: " << it->GetDeviceClass() ;
  25. }
  26. UpdateCameraList();
  27. emit sigCameraCount(n);
  28. qDebug() << "SBasler Camera Count: " << n;
  29. }
  30.  
  31. void SBaslerCameraControl::deleteAll()
  32. {
  33. //停止采集
  34. if(m_isOpenAcquire) {
  35. StopAcquire();
  36. }
  37. //关闭摄像头
  38. CloseCamera();
  39. //关闭库
  40. qDebug() << "SBaslerCameraControl deleteAll: PylonTerminate" ;
  41. PylonTerminate();
  42. qDebug() << "SBaslerCameraControl deleteAll: Close" ;
  43. }
  44.  
  45. QStringList SBaslerCameraControl::cameras()
  46. {
  47. return m_cameralist;
  48. }
  49.  
  50. void SBaslerCameraControl::UpdateCameraList()
  51. {
  52. CTlFactory& TLFactory = CTlFactory::GetInstance();
  53. ITransportLayer * pTl = TLFactory.CreateTl("BaslerGigE");
  54. DeviceInfoList_t devices;
  55. int n = pTl->EnumerateDevices(devices);
  56. CInstantCameraArray cameraArray(devices.size());
  57. if(n == 0) {
  58. qDebug() << "Cannot find Any camera!";
  59. return;
  60. }
  61. for (int i=0 ; i<cameraArray.GetSize() ; i++) {
  62. cameraArray[i].Attach(TLFactory.CreateDevice(devices[i]));
  63. string sn = cameraArray[i].GetDeviceInfo().GetSerialNumber();
  64. m_cameralist << QString::fromStdString(sn);
  65. }
  66. emit sigCameraUpdate(m_cameralist);
  67. }
  68.  
  69. void SBaslerCameraControl::CopyToImage(CGrabResultPtr pInBuffer, QImage &OutImage)
  70. {
  71. uchar* buff = (uchar*)pInBuffer->GetBuffer();
  72. int nHeight = pInBuffer->GetHeight();
  73. int nWidth = pInBuffer->GetWidth();
  74. if(m_size != QSize(nWidth, nHeight)) {
  75. m_size = QSize(nWidth, nHeight);
  76. emit sigSizeChange(m_size);
  77. }
  78. QImage imgBuff(buff, nWidth, nHeight, QImage::Format_Indexed8);
  79. OutImage = imgBuff;
  80. if(pInBuffer->GetPixelType() == PixelType_Mono8) {
  81. uchar* pCursor = OutImage.bits();
  82. if ( OutImage.bytesPerLine() != nWidth ) {
  83. for ( int y=0; y<nHeight; ++y ) {
  84. pCursor = OutImage.scanLine( y );
  85. for ( int x=0; x<nWidth; ++x ) {
  86. *pCursor =* buff;
  87. ++pCursor;
  88. ++buff;
  89. }
  90. }
  91. } else {
  92. memcpy( OutImage.bits(), buff, nWidth * nHeight );
  93. }
  94. }
  95. }
  96.  
  97. void SBaslerCameraControl::onTimerGrabImage()
  98. {
  99. if(m_isOpenAcquire) {
  100. QImage image;
  101. GrabImage(image, 5);
  102. if(!image.isNull()) {
  103. emit sigCurrentImage(image);
  104. }
  105. QTimer::singleShot(5, this, SLOT(onTimerGrabImage()));
  106. }
  107. }
  108.  
  109. int SBaslerCameraControl::OpenCamera(QString cameraSN)
  110. {
  111. try {
  112. CDeviceInfo cInfo;
  113. String_t str = String_t(cameraSN.toStdString().c_str());
  114. cInfo.SetSerialNumber(str);
  115. m_basler.Attach(CTlFactory::GetInstance().CreateDevice(cInfo));
  116. m_basler.Open();
  117. //获取触发模式
  118. getFeatureTriggerSourceType();
  119. m_isOpen = true;
  120. } catch (GenICam::GenericException &e) {
  121. OutputDebugString(L"OpenCamera Error\n");
  122. m_isOpen = false;
  123. return -2;
  124. }
  125. return 0;
  126. }
  127.  
  128. int SBaslerCameraControl::CloseCamera()
  129. {
  130. if(!m_isOpen) {
  131. return -1;
  132. }
  133. try {
  134. if(m_basler.IsOpen()) {
  135. m_basler.DetachDevice();
  136. m_basler.Close();
  137. }
  138. } catch (GenICam::GenericException &e) {
  139. OutputDebugString(LPCWSTR(e.GetDescription()));
  140. return -2;
  141. }
  142. return 0;
  143. }
  144.  
  145. void SBaslerCameraControl::setExposureTime(double time)
  146. {
  147. SetCamera(Type_Basler_ExposureTimeAbs, time);
  148. }
  149.  
  150. int SBaslerCameraControl::getExposureTime()
  151. {
  152. return QString::number(GetCamera(Type_Basler_ExposureTimeAbs)).toInt();
  153. }
  154.  
  155. int SBaslerCameraControl::getExposureTimeMin()
  156. {
  157. return DOUBLE_MIN;
  158. }
  159.  
  160. int SBaslerCameraControl::getExposureTimeMax()
  161. {
  162. return DOUBLE_MAX;
  163. }
  164.  
  165. void SBaslerCameraControl::setFeatureTriggerSourceType(QString type)
  166. {
  167. //停止采集
  168. if(m_isOpenAcquire) {
  169. StopAcquire();
  170. }
  171. if(type == "Freerun") {
  172. SetCamera(Type_Basler_Freerun);
  173. } else if(type == "Line1"){
  174. SetCamera(Type_Basler_Line1);
  175. }
  176. }
  177.  
  178. QString SBaslerCameraControl::getFeatureTriggerSourceType()
  179. {
  180. INodeMap &cameraNodeMap = m_basler.GetNodeMap();
  181. CEnumerationPtr ptrTriggerSel = cameraNodeMap.GetNode ("TriggerSelector");
  182. ptrTriggerSel->FromString("FrameStart");
  183. CEnumerationPtr ptrTrigger = cameraNodeMap.GetNode ("TriggerMode");
  184. ptrTrigger->SetIntValue(1);
  185. CEnumerationPtr ptrTriggerSource = cameraNodeMap.GetNode ("TriggerSource");
  186.  
  187. String_t str = ptrTriggerSource->ToString();
  188. m_currentMode = QString::fromLocal8Bit(str.c_str());
  189. return m_currentMode;
  190. }
  191.  
  192. void SBaslerCameraControl::setFeatureTriggerModeType(bool on)
  193. {
  194. INodeMap &cameraNodeMap = m_basler.GetNodeMap();
  195. CEnumerationPtr ptrTriggerSel = cameraNodeMap.GetNode ("TriggerSelector");
  196. ptrTriggerSel->FromString("FrameStart");
  197. CEnumerationPtr ptrTrigger = cameraNodeMap.GetNode ("TriggerMode");
  198. ptrTrigger->SetIntValue(on?1:0);
  199. }
  200.  
  201. bool SBaslerCameraControl::getFeatureTriggerModeType()
  202. {
  203. INodeMap &cameraNodeMap = m_basler.GetNodeMap();
  204. CEnumerationPtr ptrTriggerSel = cameraNodeMap.GetNode ("TriggerSelector");
  205. ptrTriggerSel->FromString("FrameStart");
  206. CEnumerationPtr ptrTrigger = cameraNodeMap.GetNode ("TriggerMode");
  207. return ptrTrigger->GetIntValue() == 1;
  208. }
  209.  
  210. void SBaslerCameraControl::SetCamera(SBaslerCameraControl::SBaslerCameraControl_Type index, double tmpValue)
  211. {
  212. INodeMap &cameraNodeMap = m_basler.GetNodeMap();
  213. switch (index) {
  214. case Type_Basler_Freerun: {
  215. CEnumerationPtr ptrTriggerSel = cameraNodeMap.GetNode ("TriggerSelector");
  216. ptrTriggerSel->FromString("FrameStart");
  217. CEnumerationPtr ptrTrigger = cameraNodeMap.GetNode ("TriggerMode");
  218. #ifdef Real_Freerun
  219. ptrTrigger->SetIntValue(0);
  220. #else //Software
  221. ptrTrigger->SetIntValue(1);
  222. CEnumerationPtr ptrTriggerSource = cameraNodeMap.GetNode ("TriggerSource");
  223. ptrTriggerSource->FromString("Software");
  224. #endif
  225. } break;
  226. case Type_Basler_Line1: {
  227. CEnumerationPtr ptrTriggerSel = cameraNodeMap.GetNode ("TriggerSelector");
  228. ptrTriggerSel->FromString("FrameStart");
  229. CEnumerationPtr ptrTrigger = cameraNodeMap.GetNode ("TriggerMode");
  230. ptrTrigger->SetIntValue(1);
  231. CEnumerationPtr ptrTriggerSource = cameraNodeMap.GetNode ("TriggerSource");
  232. ptrTriggerSource->FromString("Line1");
  233. } break;
  234. case Type_Basler_ExposureTimeAbs: {
  235. const CFloatPtr exposureTime = cameraNodeMap.GetNode("ExposureTimeAbs");
  236. exposureTime->SetValue(tmpValue);
  237. } break;
  238. case Type_Basler_GainRaw: {
  239. const CIntegerPtr cameraGen = cameraNodeMap.GetNode("GainRaw");
  240. cameraGen->SetValue(tmpValue);
  241. } break;
  242. case Type_Basler_AcquisitionFrameRateAbs: {
  243. const CBooleanPtr frameRate = cameraNodeMap.GetNode("AcquisitionFrameRateEnable");
  244. frameRate->SetValue(TRUE);
  245. const CFloatPtr frameRateABS = cameraNodeMap.GetNode("AcquisitionFrameRateAbs");
  246. frameRateABS->SetValue(tmpValue);
  247. } break;
  248. case Type_Basler_Width: {
  249. const CIntegerPtr widthPic = cameraNodeMap.GetNode("Width");
  250. widthPic->SetValue(tmpValue);
  251. } break;
  252. case Type_Basler_Height: {
  253. const CIntegerPtr heightPic = cameraNodeMap.GetNode("Height");
  254. heightPic->SetValue(tmpValue);
  255. } break;
  256. case Type_Basler_LineSource: {
  257. CEnumerationPtr ptrLineSource = cameraNodeMap.GetNode ("LineSource");
  258. ptrLineSource->SetIntValue(2);
  259. } break;
  260. default:
  261. break;
  262. }
  263. }
  264.  
  265. double SBaslerCameraControl::GetCamera(SBaslerCameraControl::SBaslerCameraControl_Type index)
  266. {
  267. INodeMap &cameraNodeMap = m_basler.GetNodeMap();
  268. switch (index) {
  269. case Type_Basler_ExposureTimeAbs: {
  270. const CFloatPtr exposureTime = cameraNodeMap.GetNode("ExposureTimeAbs");
  271. return exposureTime->GetValue();
  272. } break;
  273. case Type_Basler_GainRaw: {
  274. const CIntegerPtr cameraGen = cameraNodeMap.GetNode("GainRaw");
  275. return cameraGen->GetValue();
  276. } break;
  277. case Type_Basler_AcquisitionFrameRateAbs: {
  278. const CBooleanPtr frameRate = cameraNodeMap.GetNode("AcquisitionFrameRateEnable");
  279. frameRate->SetValue(TRUE);
  280. const CFloatPtr frameRateABS = cameraNodeMap.GetNode("AcquisitionFrameRateAbs");
  281. return frameRateABS->GetValue();
  282. } break;
  283. case Type_Basler_Width: {
  284. const CIntegerPtr widthPic = cameraNodeMap.GetNode("Width");
  285. return widthPic->GetValue();
  286. } break;
  287. case Type_Basler_Height: {
  288. const CIntegerPtr heightPic = cameraNodeMap.GetNode("Height");
  289. return heightPic->GetValue();
  290. } break;
  291. default:
  292. return -1;
  293. break;
  294. }
  295. }
  296.  
  297. long SBaslerCameraControl::StartAcquire()
  298. {
  299. m_isOpenAcquire = true;
  300. qDebug() << "SBaslerCameraControl IsGrabbing";
  301. try {
  302. qDebug() << "SBaslerCameraControl StartAcquire" << m_currentMode;
  303. if(m_currentMode == "Freerun") {
  304. m_basler.StartGrabbing(GrabStrategy_LatestImageOnly,GrabLoop_ProvidedByInstantCamera);
  305. } else if(m_currentMode == "Software") {
  306. m_basler.StartGrabbing(GrabStrategy_LatestImageOnly);
  307. onTimerGrabImage();
  308. } else if(m_currentMode == "Line1") {
  309. m_basler.StartGrabbing(GrabStrategy_OneByOne);
  310. } else if(m_currentMode == "Line2") {
  311. m_basler.StartGrabbing(GrabStrategy_OneByOne);
  312. }
  313. } catch (GenICam::GenericException &e) {
  314. OutputDebugString(L"StartAcquire error:");
  315. return -2;
  316. }
  317. return 0;
  318. }
  319.  
  320. long SBaslerCameraControl::StopAcquire()
  321. {
  322. m_isOpenAcquire = false;
  323. qDebug() << "SBaslerCameraControl StopAcquire";
  324. try {
  325. if (m_basler.IsGrabbing()) {
  326. m_basler.StopGrabbing();
  327. }
  328. } catch (GenICam::GenericException &e) {
  329. OutputDebugString(LPCWSTR(e.GetDescription()));
  330. return -2;
  331. }
  332. return 0;
  333. }
  334.  
  335. long SBaslerCameraControl::GrabImage(QImage &image, int timeout)
  336. {
  337. try {
  338. if (!m_basler.IsGrabbing()) {
  339. StartAcquire();
  340. }
  341. CGrabResultPtr ptrGrabResult;
  342. if(m_currentMode == "Freerun") {
  343. } else if(m_currentMode == "Software") {
  344. if (m_basler.WaitForFrameTriggerReady(1000, TimeoutHandling_Return)) {
  345. m_basler.ExecuteSoftwareTrigger();
  346. m_basler.RetrieveResult(timeout, ptrGrabResult,TimeoutHandling_Return);
  347. }
  348. } else if(m_currentMode == "Line1") {
  349. m_basler.RetrieveResult(timeout, ptrGrabResult, TimeoutHandling_Return);
  350. } else if(m_currentMode == "Line2") {
  351. m_basler.RetrieveResult(timeout, ptrGrabResult, TimeoutHandling_Return);
  352. }
  353. if (ptrGrabResult->GrabSucceeded()) {
  354. if (!ptrGrabResult.IsValid()) { OutputDebugString(L"GrabResult not Valid Error\n"); return -1; }
  355. EPixelType pixelType = ptrGrabResult->GetPixelType();
  356. switch (pixelType) {
  357. case PixelType_Mono8: {
  358. CopyToImage(ptrGrabResult, image);
  359. } break;
  360. case PixelType_BayerRG8: { qDebug() << "what: PixelType_BayerRG8"; } break;
  361. default: qDebug() << "what: default"; break;
  362. }
  363. } else {
  364. OutputDebugString(L"Grab Error!!!");
  365. return -3;
  366. }
  367. } catch (GenICam::GenericException &e) {
  368. OutputDebugString(L"GrabImage Error\n");
  369. return -2;
  370. } catch(...) {
  371. OutputDebugString(L"ZP 11 Shot GetParam Try 12 No know Error\n");
  372. return -1;
  373. }
  374. return 0;
  375. }

如何调用

  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5. #include "BaslerCamera/sbaslercameracontrol.h"
  6.  
  7. namespace Ui {
  8. class MainWindow;
  9. }
  10.  
  11. class MainWindow : public QMainWindow
  12. {
  13. Q_OBJECT
  14.  
  15. public:
  16. explicit MainWindow(QWidget *parent = 0);
  17. ~MainWindow();
  18.  
  19. private slots:
  20. void on_pushButton_GetExTime_clicked();
  21. void on_pushButton_SetExTime_clicked();
  22. void on_pushButton_SetMode_clicked();
  23. void on_pushButton_GetMode_clicked();
  24. void on_pushButton_CFMode_clicked();
  25. void on_comboBox_CFMode_activated(int index);
  26. void on_pushButton_Start_clicked();
  27. void on_pushButtonRotate_clicked();
  28. private:
  29. Ui::MainWindow *ui;
  30. SBaslerCameraControl* m_control = Q_NULLPTR;
  31. QMatrix m_matrix;
  32. };
  33.  
  34. #endif // MAINWINDOW_H

源文件:

  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <QDebug>
  4.  
  5. MainWindow::MainWindow(QWidget *parent) :
  6. QMainWindow(parent),
  7. ui(new Ui::MainWindow)
  8. {
  9. ui->setupUi(this);
  10. m_control = new SBaslerCameraControl(this);
  11. m_control->initSome();
  12. connect(m_control, &SBaslerCameraControl::sigCurrentImage, [=](QImage img){
  13. QPixmap pix = QPixmap::fromImage(img).transformed(m_matrix);
  14. ui->label->setPixmap(pix);
  15. ui->widget_pic->setFixedSize(pix.size());
  16. });
  17. connect(m_control, &SBaslerCameraControl::sigSizeChange, [=](QSize size){
  18. // 默认大小641,494
  19. ui->label_size->setText(QString("\345\260\272\345\257\270:%0*%1").arg(QString::number(size.width())).arg(QString::number(size.height()))); // 尺寸
  20. ui->widget_pic->setFixedSize(size);
  21. });
  22. m_control->OpenCamera(m_control->cameras().first());
  23. }
  24.  
  25. MainWindow::~MainWindow()
  26. {
  27. m_control->CloseCamera();
  28. m_control->deleteAll();
  29. delete ui;
  30. }
  31.  
  32. void MainWindow::on_pushButton_GetExTime_clicked()
  33. {
  34. ui->label_exTime->setText(QString::number(m_control->getExposureTime()));
  35. }
  36.  
  37. void MainWindow::on_pushButton_SetExTime_clicked()
  38. {
  39. m_control->setExposureTime(ui->lineEdit_exTime->text().toDouble());
  40. }
  41.  
  42. void MainWindow::on_pushButton_SetMode_clicked()
  43. {
  44. m_control->setFeatureTriggerSourceType(ui->lineEdit_SetMode->text());
  45. }
  46.  
  47. void MainWindow::on_pushButton_GetMode_clicked()
  48. {
  49. ui->label_Mode->setText(m_control->getFeatureTriggerSourceType());
  50. }
  51.  
  52. void MainWindow::on_pushButton_CFMode_clicked()
  53. {
  54. ui->label_CFMode->setText(m_control->getFeatureTriggerModeType()?"Open":"Close");
  55. }
  56.  
  57. void MainWindow::on_comboBox_CFMode_activated(int index)
  58. {
  59. m_control->setFeatureTriggerModeType(index == 0);
  60. }
  61.  
  62. void MainWindow::on_pushButton_Start_clicked()
  63. {
  64. if(ui->pushButton_Start->text() == "\345\274\200\345\247\213\351\207\207\351\233\206") {// 开始采集
  65. m_control->StartAcquire();
  66. ui->pushButton_Start->setText("\347\273\223\346\235\237\351\207\207\351\233\206");// 结束采集
  67. } else {
  68. m_control->StopAcquire();
  69. ui->pushButton_Start->setText("\345\274\200\345\247\213\351\207\207\351\233\206");// 开始采集
  70. }
  71. }
  72.  
  73. void MainWindow::on_pushButtonRotate_clicked()
  74. {
  75. m_matrix.rotate(90);
  76. }

pro文件

(注意:引用库文件的路径哦)

  1. #-------------------------------------------------
  2. #
  3. # Project created by QtCreator 2017-12-14T17:55:52
  4. #
  5. #-------------------------------------------------
  6.  
  7. QT += core gui
  8.  
  9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  10.  
  11. TARGET = Demo_BaslerCamera
  12. TEMPLATE = app
  13.  
  14. CONFIG += c++11
  15.  
  16. #--------------------------------------------Basler-------------------------------------------
  17. INCLUDEPATH += $$PWD/include
  18. LIBS += -L$$PWD/lib/Win32 -lGCBase_MD_VC120_v3_0_Basler_pylon_v5_0 -lGenApi_MD_VC120_v3_0_Basler_pylon_v5_0 -lPylonBase_MD_VC120_v5_0 -lPylonC_MD_VC120 -lPylonGUI_MD_VC120_v5_0 -lPylonUtility_MD_VC120_v5_0
  19. #----------------------------------------------------------------------------------------------
  20.  
  21. SOURCES += main.cpp\
  22. mainwindow.cpp \
  23. BaslerCamera/sbaslercameracontrol.cpp
  24.  
  25. HEADERS += mainwindow.h \
  26. BaslerCamera/sbaslercameracontrol.h
  27.  
  28. FORMS += mainwindow.ui

我把源码已经上传到码云和Github

码云

https://gitee.com/ShaShiDiZhuanLan/Demo_BaslerCamera

Github

https://github.com/ShaShiDiZhuanLan/Demo_BaslerCamera_Qt

到此这篇关于Qt(C++)调用工业相机Basler的SDK使用示例的文章就介绍到这了,更多相关Qt调用Basler的SDK内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://blog.csdn.net/u014597198/article/details/78844664

标签:

相关文章

热门资讯

yue是什么意思 网络流行语yue了是什么梗
yue是什么意思 网络流行语yue了是什么梗 2020-10-11
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
背刺什么意思 网络词语背刺是什么梗
背刺什么意思 网络词语背刺是什么梗 2020-05-22
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总
苹果12mini价格表官网报价 iPhone12mini全版本价格汇总 2020-11-13
2021年耽改剧名单 2021要播出的59部耽改剧列表
2021年耽改剧名单 2021要播出的59部耽改剧列表 2021-03-05
返回顶部