-
Notifications
You must be signed in to change notification settings - Fork 0
/
CameraClass.cpp
97 lines (82 loc) · 2.63 KB
/
CameraClass.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
// **********************************************************************
// CameraClass.cpp
// classe para manipulação de imagens de câmera
// **********************************************************************
#include <iostream>
using namespace std;
#include "CameraClass.h"
#define TAM_PIXEL 3
// **********************************************************************
//
// Constructor
// **********************************************************************
CameraClass::CameraClass(int ShowDialog, int device)
{
gHeight = gWidth = 0;
myVideoCap = imVideoCaptureCreate();
if (!myVideoCap)
{
cout << "Problemas na inicializacao da camera " << device << "." << endl;
return;
}
cout << "Inicializacao da camera " << device << " realizada." << endl;
cout << "Conexao: " << imVideoCaptureConnect(myVideoCap, device) << endl;
//imVideoCaptureLive(myVideoCap, 1);
if (ShowDialog)
imVideoCaptureShowDialog(myVideoCap, 0, NULL); // o indice 0 escolhe qual o dialogo a ser mostrado.
imVideoCaptureGetImageSize(myVideoCap, &gWidth, &gHeight);
SetSize(gWidth, gHeight);
}
//Alternativa imVideoCaptureOneFrame
void CameraClass::StartCapture()
{
imVideoCaptureLive(myVideoCap, 1);
}
// **********************************************************************
//
//
// **********************************************************************
int CameraClass::DriverOK()
{
return (myVideoCap != NULL);
}
// **********************************************************************
//
// Destructor
// **********************************************************************
CameraClass::~CameraClass()
{
imVideoCaptureDisconnect(myVideoCap);
imVideoCaptureDestroy(myVideoCap);
ImageClass::Delete();
}
// *********************************777777777777777777777777*************************************
//
// Update
// **********************************************************************
void CameraClass::Update()
{
if (!DriverOK())
return;
if (!imVideoCaptureLive(myVideoCap, -1))
{
cout <<"Retornando....\n";
return;
}
//while(!Live())
imVideoCaptureFrame(myVideoCap, GetImagePtr(), IM_RGB|IM_PACKED, 1000);
// imVideoCaptureFrame(myVideoCap, GetImagePtr(), 1000);
}
bool CameraClass::Live()
{
return imVideoCaptureLive(myVideoCap, -1);
}
// **********************************************************************
//
// OpenDialog
// **********************************************************************
void CameraClass::OpenDialog(int nDialog)
{
imVideoCaptureShowDialog(myVideoCap, nDialog, NULL); // o segundo parâmetro escolhe
// qual o dialogo a ser mostrado.
}