| 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 <sys/time.h>
|
|---|
| 13 | #endif
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | typedef unsigned char byte;
|
|---|
| 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 | //
|
|---|
| 53 | // Hardware dependant functions
|
|---|
| 54 | //
|
|---|
| 55 | static void SigAlarm(int signal);
|
|---|
| 56 |
|
|---|
| 57 | int Ioctl(int req, void *opt, const char *str=NULL);
|
|---|
| 58 |
|
|---|
| 59 | void SigInit();
|
|---|
| 60 | void Error(const char *str, int fatal=true);
|
|---|
| 61 |
|
|---|
| 62 | int StartGrab(unsigned int frame);
|
|---|
| 63 |
|
|---|
| 64 | char *GetImg(unsigned int frame);
|
|---|
| 65 |
|
|---|
| 66 | //
|
|---|
| 67 | // Execution thread which processes the pictures
|
|---|
| 68 | //
|
|---|
| 69 | void Thread();
|
|---|
| 70 | static void *MapThread(void *arg);
|
|---|
| 71 |
|
|---|
| 72 | void LoopStep(const unsigned long n);
|
|---|
| 73 |
|
|---|
| 74 | public:
|
|---|
| 75 | Camera();
|
|---|
| 76 | virtual ~Camera();
|
|---|
| 77 |
|
|---|
| 78 | //
|
|---|
| 79 | // Starts, stops the execution
|
|---|
| 80 | //
|
|---|
| 81 | void Loop(const unsigned long nof=0);
|
|---|
| 82 | void ExitLoop()
|
|---|
| 83 | {
|
|---|
| 84 | fStop = 1;
|
|---|
| 85 | while (IsRunning())
|
|---|
| 86 | usleep(1);
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | //
|
|---|
| 90 | // flag if the execution is running or not
|
|---|
| 91 | //
|
|---|
| 92 | int IsRunning() const { return fRunning; }
|
|---|
| 93 |
|
|---|
| 94 | //
|
|---|
| 95 | // Execution of one frame - this function may be overloaded!
|
|---|
| 96 | //
|
|---|
| 97 | virtual void ProcessFrame(const unsigned long n,
|
|---|
| 98 | byte *img, struct timeval *tm);
|
|---|
| 99 |
|
|---|
| 100 | //
|
|---|
| 101 | // hardware features
|
|---|
| 102 | //
|
|---|
| 103 | void SetPicPar(int bright, int hue, int contrast);
|
|---|
| 104 | void GetPicPar(int *bright, int *hue, int *contrast);
|
|---|
| 105 |
|
|---|
| 106 | ClassDef(Camera, 0)
|
|---|
| 107 | };
|
|---|
| 108 |
|
|---|
| 109 | #endif
|
|---|