1 | #ifndef CAMERA_H
|
---|
2 | #define CAMERA_H
|
---|
3 |
|
---|
4 | #ifdef __CINT__
|
---|
5 | typedef unsigned long int pthread_t;
|
---|
6 | struct pthread_mutex_t;
|
---|
7 | struct pthread_cond_t;
|
---|
8 | struct timeval;
|
---|
9 | #else
|
---|
10 | #include <TROOT.h>
|
---|
11 | #include <pthread.h>
|
---|
12 | #include <unistd.h>
|
---|
13 | #include <sys/time.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 | #include "PixClient.h"
|
---|
17 |
|
---|
18 | class Camera
|
---|
19 | {
|
---|
20 | private:
|
---|
21 | //
|
---|
22 | // Geometry
|
---|
23 | //
|
---|
24 | static const int cols = 768;
|
---|
25 | static const int rows = 576;
|
---|
26 | static const int depth = 3;
|
---|
27 |
|
---|
28 | //
|
---|
29 | // Hardware Descriptors
|
---|
30 | //
|
---|
31 | int fd;
|
---|
32 | int iBufferSize;
|
---|
33 | int iOffsets[2];
|
---|
34 |
|
---|
35 | char *pMapBuffer;
|
---|
36 |
|
---|
37 | //
|
---|
38 | // Thread interface
|
---|
39 | //
|
---|
40 | unsigned long fNum;
|
---|
41 |
|
---|
42 | int fStop;
|
---|
43 | int fRunning;
|
---|
44 |
|
---|
45 | char fImg[cols*rows];
|
---|
46 | struct timeval fTime;
|
---|
47 |
|
---|
48 | pthread_t fThread;
|
---|
49 | pthread_mutex_t fMux;
|
---|
50 | pthread_cond_t fCond;
|
---|
51 |
|
---|
52 | PixClient &fClient;
|
---|
53 |
|
---|
54 | //
|
---|
55 | // Hardware dependant functions
|
---|
56 | //
|
---|
57 | static void SigAlarm(int signal);
|
---|
58 |
|
---|
59 | int Ioctl(int req, void *opt, const char *str=NULL);
|
---|
60 |
|
---|
61 | void SigInit();
|
---|
62 | void Error(const char *str, int fatal=true);
|
---|
63 |
|
---|
64 | int StartGrab(unsigned int frame);
|
---|
65 |
|
---|
66 | char *GetImg(unsigned int frame);
|
---|
67 |
|
---|
68 | //
|
---|
69 | // Execution thread which processes the pictures
|
---|
70 | //
|
---|
71 | void Thread();
|
---|
72 | static void *MapThread(void *arg);
|
---|
73 |
|
---|
74 | void LoopStep(const unsigned long n);
|
---|
75 |
|
---|
76 | public:
|
---|
77 | Camera(PixClient &client);
|
---|
78 | virtual ~Camera();
|
---|
79 |
|
---|
80 | //
|
---|
81 | // Starts, stops the execution
|
---|
82 | //
|
---|
83 | void Loop(const unsigned long nof=0);
|
---|
84 | void ExitLoop()
|
---|
85 | {
|
---|
86 | fStop = 1;
|
---|
87 | while (IsRunning())
|
---|
88 | usleep(1);
|
---|
89 | }
|
---|
90 |
|
---|
91 | //
|
---|
92 | // flag if the execution is running or not
|
---|
93 | //
|
---|
94 | int IsRunning() const { return fRunning; }
|
---|
95 |
|
---|
96 | //
|
---|
97 | // Execution of one frame - this function may be overloaded!
|
---|
98 | //
|
---|
99 | //virtual void ProcessFrame(const unsigned long n,
|
---|
100 | // byte *img, struct timeval *tm);
|
---|
101 |
|
---|
102 | //
|
---|
103 | // hardware features
|
---|
104 | //
|
---|
105 | void SetPicPar(int bright, int hue, int contrast);
|
---|
106 | void GetPicPar(int *bright, int *hue, int *contrast);
|
---|
107 |
|
---|
108 | ClassDef(Camera, 0)
|
---|
109 | };
|
---|
110 |
|
---|
111 | #endif
|
---|