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