我是靠谱客的博主 笑点低大山,这篇文章主要介绍linux 下qt调用大恒图像水星相机,现在分享给大家,希望可以做个参考。

1. 开发环境

系统 :ubuntu 19.04

开发工具 : Qt Creator4.3.1

语言 : linux C

2. 程序功能

金星相机的显示,

金星相机的存图

金星相机曝光

触发模式

像素格式

触发源等的设

3.

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
//MainWindos #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_pobjAcqThread(NULL), m_hDevice(NULL), m_pobjShowImgTimer(NULL), m_bAcquisitionStart(false) { ui->setupUi(this); m_pobjShowImgTimer = new QTimer(this); connect(m_pobjShowImgTimer, SIGNAL(timeout()), this, SLOT(slotShowImage())); // // Connect image save signal and slot non-blocking // connect(this, SIGNAL(SigSaveImage()), this, SLOT(slotSaveImageFile()), Qt::QueuedConnection); // Release GxiApi libary GX_STATUS emStatus = GX_STATUS_SUCCESS; emStatus = GXInitLib(); if (emStatus != GX_STATUS_SUCCESS) { ShowErrorString(emStatus); } UpdateUI(); } MainWindow::~MainWindow() { if (m_bAcquisitionStart) { m_pobjAcqThread->m_bAcquisitionThreadFlag = false; m_pobjAcqThread->quit(); m_pobjAcqThread->wait(); } // Release GxiApi libary GX_STATUS emStatus = GX_STATUS_SUCCESS; emStatus = GXCloseLib(); if (emStatus != GX_STATUS_SUCCESS) { ShowErrorString(emStatus); } delete ui; } void MainWindow::ClearUI() { // Clear Items in ComboBox ui->PixelFormat->clear(); ui->TriggerMode->clear(); ui->TriggerSource->clear(); // Clear show image label ui->ImageLabel->clear(); return; } //---------------------------------------------------------------------------------- void MainWindow::UpdateUI() { ui->UpdateDeviceList->setEnabled(!m_bOpen); ui->DeviceList->setEnabled(!m_bOpen); ui->OpenDevice->setEnabled(ui->DeviceList->count() > 0 && !m_bOpen); ui->CloseDevice->setEnabled(m_bOpen); ui->Capture_Control->setEnabled(m_bOpen); ui->StartAcquisition->setEnabled(!m_bAcquisitionStart); ui->StopAcquisition->setEnabled(m_bAcquisitionStart); ui->PixelFormat->setEnabled(!m_bAcquisitionStart); } //---------------------------------------------------------------------------------- /** /Show images acquired and processed(slot) param[in] param[out] return void */ //---------------------------------------------------------------------------------- void MainWindow::slotShowImage() { // If acquisition did not started if (!m_bAcquisitionStart) { return; } // Get Image from image show queue, if image show queue is empty, return directly QImage* qobjImgShow = m_pobjAcqThread->PopFrontFromShowImageDeque(); if(qobjImgShow == NULL) { return; } if (m_bSaveImage) { QString pictrureName="../img/1.jpg"; qobjImgShow->save(pictrureName, "JPG", 100); } // Display the image QImage objImgScaled = qobjImgShow->scaled(ui->ImageLabel->width(), ui->ImageLabel->height(), Qt::IgnoreAspectRatio, Qt::FastTransformation); ui->ImageLabel->setPixmap(QPixmap::fromImage(objImgScaled)); // Display is finished, push back image buffer to buffer queue m_pobjAcqThread->PushBackToEmptyBufferDeque(qobjImgShow); // Calculate image showing frame rate m_ui32ShowCount++; // m_objFps.IncreaseFrameNum(); return; } //---------------------------------------------------------------------------------- /** brief Enumerate Devcie List, Get baseinfo of these devices param[in] param[out] return */ //---------------------------------------------------------------------------------- void MainWindow::UpdateDeviceList() { // Release GxiApi libary GX_STATUS emStatus = GX_STATUS_SUCCESS; // If base info exist, delete it firstly //RELEASE_ALLOC_ARR(m_pstBaseInfo); // Enumerate Devcie List emStatus = GXUpdateDeviceList(&m_ui32DeviceNum, ENUMRATE_TIME_OUT); GX_VERIFY(emStatus); // If avalible devices enumerated, get base info of enumerate devices if(m_ui32DeviceNum > 0) { // Alloc resourses for device baseinfo try { m_pstBaseInfo = new GX_DEVICE_BASE_INFO[m_ui32DeviceNum]; } catch (std::bad_alloc &e) { QMessageBox::about(NULL, "Allocate memory error", "Cannot allocate memory, please exit this app!"); // RELEASE_ALLOC_MEM(m_pstBaseInfo); return; } // Set size of function "GXGetAllDeviceBaseInfo" size_t nSize = m_ui32DeviceNum * sizeof(GX_DEVICE_BASE_INFO); // Get all device baseinfo emStatus = GXGetAllDeviceBaseInfo(m_pstBaseInfo, &nSize); if (emStatus != GX_STATUS_SUCCESS) { RELEASE_ALLOC_ARR(m_pstBaseInfo); ShowErrorString(emStatus); // Reset device number m_ui32DeviceNum = 0; return; } } return; } //---------------------------------------------------------------------------------- /** Open Device param[in] param[out] return void */ //---------------------------------------------------------------------------------- void MainWindow::OpenDevice() { GX_STATUS emStatus = GX_STATUS_SUCCESS; emStatus = GXOpenDeviceByIndex(ui->DeviceList->currentIndex() + 1, &m_hDevice); GX_VERIFY(emStatus); // isOpen flag set true m_bOpen = true; return; } //---------------------------------------------------------------------------------- /** Setup acquisition thread param[in] param[out] return void */ //---------------------------------------------------------------------------------- void MainWindow::SetUpAcquisitionThread() { // if Acquisition thread is on Stop acquisition thread if (m_pobjAcqThread != NULL) { m_pobjAcqThread->m_bAcquisitionThreadFlag = false; m_pobjAcqThread->quit(); m_pobjAcqThread->wait(); // Release acquisition thread object RELEASE_ALLOC_MEM(m_pobjAcqThread); } // Instantiation acquisition thread try { m_pobjAcqThread = new CAcquisitionThread; } catch (std::bad_alloc &e) { QMessageBox::about(NULL, "Allocate memory error", "Cannot allocate memory, please exit this app!"); RELEASE_ALLOC_MEM(m_pobjAcqThread); return; } // // Connect error signal and error handler // connect(m_pobjAcqThread, SIGNAL(SigAcquisitionError(QString)), this, // SLOT(slotAcquisitionErrorHandler(QString)), Qt::QueuedConnection); // connect(m_pobjAcqThread, SIGNAL(SigImageProcError(VxInt32)), this, // SLOT(slotImageProcErrorHandler(VxInt32)), Qt::QueuedConnection); return; } //---------------------------------------------------------------------------------- /** Check if MultiROI is opened(This sample does not support MultiROI) param[in] param[out] return bool true MultiROI is on or not implemented false MultiROI is off */ //---------------------------------------------------------------------------------- bool MainWindow::CheckMultiROIOn() { GX_STATUS emStatus = GX_STATUS_SUCCESS; int64_t emRegionSendMode = GX_REGION_SEND_SINGLE_ROI_MODE; bool bRegionMode = false; emStatus = GXIsImplemented(m_hDevice, GX_ENUM_REGION_SEND_MODE, &bRegionMode); if (emStatus != GX_STATUS_SUCCESS) { ShowErrorString(emStatus); } if (bRegionMode) { emStatus = GXGetEnum(m_hDevice, GX_ENUM_REGION_SEND_MODE, &emRegionSendMode); if (emStatus != GX_STATUS_SUCCESS) { ShowErrorString(emStatus); } } if (emRegionSendMode == GX_REGION_SEND_MULTI_ROI_MODE) { QMessageBox::about(this, "MultiROI not supported", "This sample does not support MultiROI!n" "please change region mode!"); return true; } return false; } //---------------------------------------------------------------------------------- /** Enable all UI Groups except Camera select group param[in] param[out] return void */ //---------------------------------------------------------------------------------- void MainWindow::EnableUI() { ui->Capture_Control->setEnabled(true); } //---------------------------------------------------------------------------------- /** Disable all UI Groups except Camera select group param[in] param[out] return void */ //---------------------------------------------------------------------------------- void MainWindow::DisableUI() { ui->Capture_Control->setEnabled(false); } //---------------------------------------------------------------------------------- /** Set device acquisition buffer number. param[in] param[out] return bool true : Setting success false: Setting fail */ //---------------------------------------------------------------------------------- bool MainWindow::SetAcquisitionBufferNum() { GX_STATUS emStatus = GX_STATUS_SUCCESS; uint64_t ui64BufferNum = 0; int64_t i64PayloadSize = 0; // Get device current payload size emStatus = GXGetInt(m_hDevice, GX_INT_PAYLOAD_SIZE, &i64PayloadSize); if (emStatus != GX_STATUS_SUCCESS) { ShowErrorString(emStatus); return false; } // Set buffer quantity of acquisition queue if (i64PayloadSize == 0) { QMessageBox::about(this, "Set Buffer Number", "Set acquisiton buffer number failed : Payload size is 0 !"); return false; } // Calculate a reasonable number of Buffers for different payload size // Small ROI and high frame rate will requires more acquisition Buffer const size_t MAX_MEMORY_SIZE = 8 * 1024 * 1024; // The maximum number of memory bytes available for allocating frame Buffer const size_t MIN_BUFFER_NUM = 5; // Minimum frame Buffer number const size_t MAX_BUFFER_NUM = 450; // Maximum frame Buffer number ui64BufferNum = MAX_MEMORY_SIZE / i64PayloadSize; ui64BufferNum = (ui64BufferNum <= MIN_BUFFER_NUM) ? MIN_BUFFER_NUM : ui64BufferNum; ui64BufferNum = (ui64BufferNum >= MAX_BUFFER_NUM) ? MAX_BUFFER_NUM : ui64BufferNum; emStatus = GXSetAcqusitionBufferNumber(m_hDevice, ui64BufferNum); if (emStatus != GX_STATUS_SUCCESS) { ShowErrorString(emStatus); return false; } // Transfer buffer number to acquisition thread class for using GXDQAllBufs m_pobjAcqThread->m_ui64AcquisitionBufferNum = ui64BufferNum; return true; } //---------------------------------------------------------------------------------- /** Device start acquisition and start acquisition thread param[in] param[out] return void */ //---------------------------------------------------------------------------------- void MainWindow::StartAcquisition() { GX_STATUS emStatus = GX_STATUS_SUCCESS; emStatus = GXStreamOn(m_hDevice); GX_VERIFY(emStatus); // Set acquisition thread run flag m_pobjAcqThread->m_bAcquisitionThreadFlag = true; // Acquisition thread start m_pobjAcqThread->start(); // isStart flag set true m_bAcquisitionStart = true; return; } //---------------------------------------------------------------------------------- /** Device stop acquisition and stop acquisition thread param[in] param[out] return void */ //---------------------------------------------------------------------------------- void MainWindow::StopAcquisition() { GX_STATUS emStatus = GX_STATUS_SUCCESS; m_pobjAcqThread->m_bAcquisitionThreadFlag = false; m_pobjAcqThread->quit(); m_pobjAcqThread->wait(); // Turn off stream emStatus = GXStreamOff(m_hDevice); GX_VERIFY(emStatus); // isStart flag set false m_bAcquisitionStart = false; return; } //---------------------------------------------------------------------------------- /** Close Device param[in] param[out] return void */ //---------------------------------------------------------------------------------- void MainWindow::CloseDevice() { GX_STATUS emStatus = GX_STATUS_SUCCESS; // Stop Timer m_pobjShowImgTimer->stop(); // m_pobjShowFrameRateTimer->stop(); // Stop acquisition thread before close device if acquisition did not stoped if (m_bAcquisitionStart) { m_pobjAcqThread->m_bAcquisitionThreadFlag = false; m_pobjAcqThread->quit(); m_pobjAcqThread->wait(); // isStart flag reset m_bAcquisitionStart = false; } // Release acquisition thread object RELEASE_ALLOC_MEM(m_pobjAcqThread); //Close Device emStatus = GXCloseDevice(m_hDevice); GX_VERIFY(emStatus); // isOpen flag reset m_bOpen = false; // release device handle m_hDevice = NULL; // Update Mainwindow UpdateUI(); return; } //---------------------------------------------------------------------------------- /** Refresh Main window when execute usersetload param[in] param[out] return void */ //---------------------------------------------------------------------------------- void MainWindow::slotRefreshMainWindow() { // Clear Items in ComboBox ui->PixelFormat->clear(); ui->TriggerMode->clear(); ui->TriggerSource->clear(); this->GetDeviceInitParam(); return; } //---------------------------------------------------------------------------------- /** defult show lineEdit settings param[in] param[out] return void */ //---------------------------------------------------------------------------------- void MainWindow::setLineEditSettings() { GX_STATUS emStatus = GX_STATUS_SUCCESS; double dValue = 0; emStatus = GXGetFloat(m_hDevice, GX_FLOAT_EXPOSURE_TIME, &dValue); ui->lineEdit->setText(QString::number(dValue)); emStatus = GXGetFloat(m_hDevice, GX_FLOAT_GAIN, &dValue); ui->lineEdit_2->setText(QString::number(dValue)); int64_t nValue = 0; emStatus = GXGetInt(m_hDevice, GX_INT_CENTER_WIDTH, &nValue); ui->lineEdit_3->setText(QString::number(nValue)); emStatus = GXGetInt(m_hDevice, GX_INT_CENTER_HEIGHT, &nValue); ui->lineEdit_4->setText(QString::number(nValue)); } //---------------------------------------------------------------------------------- /** Get parameters from Device and set them into UI items param[in] param[out] return void */ //---------------------------------------------------------------------------------- void MainWindow::GetDeviceInitParam() { GX_STATUS emStatus = GX_STATUS_SUCCESS; // Disable all items to avoid user input while initializing DisableUI(); // Init pixel format combobox entrys emStatus = InitComboBox(m_hDevice, ui->PixelFormat, GX_ENUM_PIXEL_FORMAT); if (emStatus != GX_STATUS_SUCCESS) { CloseDevice(); GX_VERIFY(emStatus); } // Init trigger mode combobox entrys emStatus = InitComboBox(m_hDevice, ui->TriggerMode, GX_ENUM_TRIGGER_MODE); if (emStatus != GX_STATUS_SUCCESS) { CloseDevice(); GX_VERIFY(emStatus); } // If Trigger mode is on, set Flag to true if (ui->TriggerMode->itemData(ui->TriggerMode->currentIndex()).value<int64_t>() == GX_TRIGGER_MODE_ON) { m_bTriggerModeOn = true; } else { m_bTriggerModeOn = false; } // Init trigger source combobox entrys emStatus = InitComboBox(m_hDevice, ui->TriggerSource, GX_ENUM_TRIGGER_SOURCE); if (emStatus != GX_STATUS_SUCCESS) { CloseDevice(); GX_VERIFY(emStatus); } // If Trigger software is on, set Flag to true if (ui->TriggerSource->itemData(ui->TriggerSource->currentIndex()).value<int64_t>() == GX_TRIGGER_SOURCE_SOFTWARE) { m_bSoftTriggerOn = true; } else { m_bSoftTriggerOn = false; } // Device support frame control or not bool bFrameRateControl = false; emStatus = GXIsImplemented(m_hDevice, GX_ENUM_ACQUISITION_FRAME_RATE_MODE, &bFrameRateControl); if (emStatus != GX_STATUS_SUCCESS) { CloseDevice(); GX_VERIFY(emStatus); } EnableUI(); return; } void MainWindow::on_UpdateDeviceList_clicked() { QString szDeviceDisplayName; ui->DeviceList->clear(); // Enumerate Devices UpdateDeviceList(); // If enumerate no device, return if (m_ui32DeviceNum == 0) { // Update Mainwindow UpdateUI(); return; } // Add items and display items on ComboBox for (uint32_t i = 0; i < m_ui32DeviceNum; i++) { szDeviceDisplayName.sprintf("%s", m_pstBaseInfo[i].szDisplayName); ui->DeviceList->addItem(QString(szDeviceDisplayName)); } // Focus on the first device ui->DeviceList->setCurrentIndex(0); // Update Mainwindow UpdateUI(); return; } void MainWindow::on_OpenDevice_clicked() { // Open Device OpenDevice(); // Do not init device or get init params when open failed if (!m_bOpen) { return; } // Setup acquisition thread SetUpAcquisitionThread(); // // Setup all Dialogs slotRefreshMainWindow(); // // Transfer Device handle to acquisition thread class m_pobjAcqThread->GetDeviceHandle(m_hDevice); setLineEditSettings(); // Update Mainwindow UpdateUI(); return; } void MainWindow::on_StartAcquisition_clicked() { bool bMultiRoiOn = false; // This sample does not support MultiROI, acquisition will not started when multiROI is on. bMultiRoiOn = CheckMultiROIOn(); if (bMultiRoiOn) { return; } bool bSetDone = false; // Set acquisition buffer number bSetDone = SetAcquisitionBufferNum(); if (!bSetDone) { return; } bool bPrepareDone = false; // Alloc resource for image acquisition bPrepareDone = m_pobjAcqThread->PrepareForShowImg(); if (!bPrepareDone) { return; } // Device start acquisition and start acquisition thread StartAcquisition(); // Do not start timer when acquisition start failed if (!m_bAcquisitionStart) { return; } // Start image showing timer(Image show frame rate = 1000/nShowTimerInterval) // Refresh interval 33ms const int nShowTimerInterval = 33; m_pobjShowImgTimer->start(nShowTimerInterval); // Update Mainwindow UpdateUI(); return; } void MainWindow::on_CloseDevice_clicked() { // Close Device CloseDevice(); // Update Mainwindow UpdateUI(); return; } void MainWindow::on_StopAcquisition_clicked() { // Stop Acquisition StopAcquisition(); // Stop timer m_pobjShowImgTimer->stop(); // Update Mainwindow UpdateUI(); } void MainWindow::on_PixelFormat_activated(int index) { GX_STATUS emStatus = GX_STATUS_SUCCESS; // Set Pixel format emStatus = GXSetEnum(m_hDevice, GX_ENUM_PIXEL_FORMAT, ui->PixelFormat->itemData(index).value<int64_t>()); GX_VERIFY(emStatus); } void MainWindow::on_TriggerMode_activated(int index) { GX_STATUS emStatus = GX_STATUS_SUCCESS; // Set trigger Mode emStatus = GXSetEnum(m_hDevice, GX_ENUM_TRIGGER_MODE, ui->TriggerMode->itemData(index).value<int64_t>()); GX_VERIFY(emStatus); // If Trigger mode is on, set Flag to true if (ui->TriggerMode->itemData(index).value<int64_t>() == GX_TRIGGER_MODE_ON) { m_bTriggerModeOn = true; } else { m_bTriggerModeOn = false; } // If Trigger software is on, set Flag to true if (ui->TriggerSource->itemData(ui->TriggerSource->currentIndex()).value<int64_t>() == GX_TRIGGER_SOURCE_SOFTWARE) { m_bSoftTriggerOn = true; } else { m_bSoftTriggerOn = false; } //Update Mainwindow UpdateUI(); } void MainWindow::on_TriggerSource_activated(int index) { GX_STATUS emStatus = GX_STATUS_SUCCESS; // Set trigger Source emStatus = GXSetEnum(m_hDevice, GX_ENUM_TRIGGER_SOURCE, ui->TriggerSource->itemData(index).value<int64_t>()); GX_VERIFY(emStatus); if (ui->TriggerSource->itemData(index).value<int64_t>() == GX_TRIGGER_SOURCE_SOFTWARE) { m_bSoftTriggerOn = true; } else { m_bSoftTriggerOn = false; } //Update Mainwindow UpdateUI(); return; } void MainWindow::on_checkBox_clicked() { if( ui->checkBox->isChecked() ) { m_bSaveImage=true; } else if(ui->checkBox->isChecked() == false) { m_bSaveImage=false; } } void MainWindow::on_lineEdit_editingFinished() { QString a; a=ui->lineEdit->text(); GX_STATUS emStatus = GX_STATUS_SUCCESS; emStatus = GXSetFloat(m_hDevice, GX_FLOAT_EXPOSURE_TIME, a.toDouble()); // if(emStatus!=GX_STATUS_SUCCESS) // { // QMessageBox::about(NULL, "Error", "曝光设置失败"); // } GX_VERIFY(emStatus); } void MainWindow::on_lineEdit_2_editingFinished() { QString a; a=ui->lineEdit_2->text(); GX_STATUS emStatus = GX_STATUS_SUCCESS; emStatus = GXSetEnum(m_hDevice, GX_ENUM_GAIN_SELECTOR, GX_GAIN_SELECTOR_ALL); //VERIFY_STATUS_RET(emStatus); emStatus = GXSetFloat(m_hDevice, GX_FLOAT_GAIN, a.toFloat()); //VERIFY_STATUS_RET(emStatus); GX_VERIFY(emStatus); } void MainWindow::on_lineEdit_3_editingFinished() { QString a; a=ui->lineEdit_3->text(); GX_STATUS emStatus = GX_STATUS_SUCCESS; emStatus = GXSetInt(m_hDevice,GX_INT_CENTER_HEIGHT, a.toInt()); GX_VERIFY(emStatus); } void MainWindow::on_lineEdit_4_editingFinished() { QString a; a=ui->lineEdit_4->text(); GX_STATUS emStatus = GX_STATUS_SUCCESS; emStatus = GXSetInt(m_hDevice,GX_INT_CENTER_WIDTH, a.toInt()); GX_VERIFY(emStatus); }

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//mainwindos.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #define ENUMRATE_TIME_OUT 200 //----------- #include <QMainWindow> #include <QMessageBox> #include"GxIAPI.h" #include"DxImageProc.h" #include"AcquisitionThread.h" #include"Common.h" namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_UpdateDeviceList_clicked(); void on_OpenDevice_clicked(); void on_StartAcquisition_clicked(); /// Show images acquired and processed void slotShowImage(); void on_CloseDevice_clicked(); void on_StopAcquisition_clicked(); void on_PixelFormat_activated(int index); void on_TriggerMode_activated(int index); void on_TriggerSource_activated(int index); /// Refresh Main window when execute usersetload void slotRefreshMainWindow(); void on_checkBox_clicked(); void on_lineEdit_editingFinished(); void on_lineEdit_2_editingFinished(); void on_lineEdit_3_editingFinished(); void on_lineEdit_4_editingFinished(); private: Ui::MainWindow *ui; //---------------------- void setLineEditSettings(); /// Clear Mainwindow items void ClearUI(); /// Enable all UI Groups void EnableUI(); /// Disable all UI Groups void DisableUI(); /// Update all items status on MainWindow void UpdateUI(); /// Update device list void UpdateDeviceList(); /// Setup acquisition thread void SetUpAcquisitionThread(); /// Open device selected void OpenDevice(); /// Close device opened void CloseDevice(); /// Set device acquisition buffer number. bool SetAcquisitionBufferNum(); /// Get parameters from opened device void GetDeviceInitParam(); /// Check if MultiROI is on bool CheckMultiROIOn(); /// Device start acquisition and start acquisition thread void StartAcquisition(); /// Device stop acquisition and stop acquisition thread void StopAcquisition(); CAcquisitionThread *m_pobjAcqThread; ///< Child image acquisition and process thread GX_DEV_HANDLE m_hDevice; ///< Device Handle GX_DEVICE_BASE_INFO *m_pstBaseInfo; ///< Pointer struct of Device info uint32_t m_ui32DeviceNum; ///< Device number enumerated bool m_bOpen; ///< Flag : camera is opened or not bool m_bAcquisitionStart; ///< Flag : camera is acquiring or not bool m_bTriggerModeOn; ///< Flag : Trigger mode is on or not bool m_bSoftTriggerOn; ///< Flag : Trigger software is on or not bool m_bSaveImage; ///< Flag : Save one image when it is true //int m_freamNumber; /// Fream Number; // QImage m_objImageForSave; ///< For image saving uint32_t m_ui32ShowCount; ///< Frame count of image show QTimer *m_pobjShowImgTimer; ///< Timer of Show Image //---------------------- }; #endif // MAINWINDOW_H

只截取了一部分重要的代码,也在学习中,欢迎大家指正

最后

以上就是笑点低大山最近收集整理的关于linux 下qt调用大恒图像水星相机的全部内容,更多相关linux内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(56)

评论列表共有 0 条评论

立即
投稿
返回
顶部