Repository navigation
Expand file tree
/
Copy pathcamera.h
More file actions
106 lines (86 loc) · 2.06 KB
/
Copy pathcamera.h
File metadata and controls
106 lines (86 loc) · 2.06 KB
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
//
// C++ Interface: camera
//
// Description:
//
//
// Author: Valdur Kaldvee, Margus Ernits, Erik Kaju
//
//
#ifndef CAMERA_H
#define CAMERA_H
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <string>
#define CAMERA_FRONT "51208051"
#define CAMERA_LEFT "51209851"
#define CAMERA_RIGHT "41303651"
#ifdef XI
#warning "XIAPI defined"
#include <xiApi.h>
#define HandleResult(res,place) if (res!=XI_OK) {printf("Error after %s (%d)",place,res);exit(1);}
#endif
/**
This Class holds camera information
@author Valdur Kaldvee, Margus Ernits <margus.ernits@itcollege.ee>
*/
using namespace std;
class Camera{
public:
Camera();
~Camera();
void reOpen();
void close();
// image buffer
/*!
\fn Camera::getCapture()
*/
CvCapture * getCapture()
{
return capture;
}
#ifdef XI
static HANDLE xiH_front;
static HANDLE xiH_left;
static HANDLE xiH_right;
static bool isCameraEnabled(const char* deviceIdOrSerial) {
HANDLE checkCameraHandle = NULL;
if (deviceIdOrSerial == CAMERA_FRONT) {
checkCameraHandle = xiH_front;
} else if (deviceIdOrSerial == CAMERA_LEFT) {
checkCameraHandle = xiH_left;
} else if (deviceIdOrSerial == CAMERA_RIGHT) {
checkCameraHandle = xiH_right;
} else return false;
if (checkCameraHandle == NULL) return false;
return true;
}
static XI_RETURN stat;
HANDLE getXI_CaptureFront() {
return xiH_front;
}
HANDLE getXI_CaptureLeft() {
return xiH_left;
}
HANDLE getXI_CaptureRight() {
return xiH_right;
}
void setupXICamera(HANDLE* xiH, XI_RETURN* stat, const char* deviceIdOrSerial);
#endif
IplImage* getImg()
{
if(img) cvReleaseImage(&img);
img=cvLoadImage(pictureFilename);
if(!img){
printf("Could not load image file: %s\n",pictureFilename);
exit(1);
}
return img;
}
IplImage* img;
public:
CvCapture * capture;
char * pictureFilename;
};
#endif