-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_camera.cpp
103 lines (79 loc) · 2.6 KB
/
test_camera.cpp
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
///////////////////////////////////////////////////////////////////////////////
// File generated by HDevelop for HALCON/C++ Version 23.11.0.0
// Non-ASCII strings in this file are encoded in local-8-bit encoding (utf8).
// Ensure that the interface encoding is set to locale encoding by calling
// SetHcppInterfaceStringEncodingIsUtf8(false) at the beginning of the program.
//
// Please note that non-ASCII characters in string constants are exported
// as octal codes in order to guarantee that the strings are correctly
// created on all systems, independent on any compiler settings.
//
// Source files with different encoding should not be mixed in one project.
///////////////////////////////////////////////////////////////////////////////
#include "HalconCpp.h"
#include "HDevThread.h"
using namespace HalconCpp;
#ifndef NO_EXPORT_MAIN
// Main procedure
void action()
{
// Local iconic variables
HObject ho_Image;
// Local control variables
HTuple hv_WindowHandle, hv_AcqHandle;
//Image Acquisition 01: Code generated by Image Acquisition 01
SetWindowAttr("background_color","black");
OpenWindow(0,0,512,512,0,"visible","",&hv_WindowHandle);
HDevWindowStack::Push(hv_WindowHandle);
OpenFramegrabber("Video4Linux2", 1, 1, 0, 0, 0, 0, "progressive", 8, "default",
-1, "false", "auto", "video1", 0, -1, &hv_AcqHandle);
GrabImageStart(hv_AcqHandle, -1);
while (true)
{
GrabImageAsync(&ho_Image, hv_AcqHandle, -1);
if (HDevWindowStack::IsOpen())
DispObj(ho_Image, HDevWindowStack::GetActive());
//Image Acquisition 01: Do something
}
CloseFramegrabber(hv_AcqHandle);
}
#ifndef NO_EXPORT_APP_MAIN
int main(int argc, char *argv[])
{
int ret = 0;
try
{
#if defined(_WIN32)
SetSystem("use_window_thread", "true");
#endif
// file was stored with local-8-bit encoding
// -> set the interface encoding accordingly
SetHcppInterfaceStringEncodingIsUtf8(false);
// Default settings used in HDevelop (can be omitted)
SetSystem("width", 512);
SetSystem("height", 512);
action();
}
catch (HException &exception)
{
fprintf(stderr," Error #%u in %s: %s\n", exception.ErrorCode(),
exception.ProcName().TextA(),
exception.ErrorMessage().TextA());
ret = 1;
}
#if defined(_WIN32)
// On Windows socket communication is no longer possible after returning
// from main, so HALCON cannot return floating licenses automatically.
try
{
SetSystem("return_license", "true");
}
catch (...)
{
// Ignore any errors that might occur when returning the license.
}
#endif
return ret;
}
#endif
#endif