Changeset 18626
- Timestamp:
- 09/18/16 14:52:24 (8 years ago)
- Location:
- trunk/FACT++/drive
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/drive/Camera.cc
r18618 r18626 24 24 #include "Camera.h" 25 25 26 #include "MLog.h" 27 #include "MLogManip.h" 26 #include <iostream> 28 27 29 28 #include "MVideo.h" 30 29 #include "PixClient.h" 31 32 //ClassImp(Camera);33 30 34 31 using namespace std; … … 55 52 gettimeofday(&fTime, NULL); 56 53 57 const Int_t W = fVideo->GetWidth(); 58 const Int_t H = fVideo->GetHeight(); 59 /* 60 const Bool_t crop = W!=768 || H!=576; 54 #if 1 55 for (int y=0; y<576; y++) 56 for (int x=0; x<768; x++) 57 { 58 const Int_t p = (x+y*768)*4; 59 fImg[x+y*768] = ((UInt_t)img[p+1]+(UInt_t)img[p+2]+(UInt_t)img[p+3])/3; 60 } 61 #endif 61 62 62 // FIXME: This only works for one RGB24 63 if (!crop) 64 { 65 // FIXME: Grey scale assumed! 66 const unsigned char *end = img + 768*576*depth; 67 char *beg = fImg; 68 while (img < end) 69 { 70 *beg++ = *img; 71 img += depth; 72 } 73 } 74 else 75 */ 76 { 77 const Int_t w = TMath::Min(W, 768); 78 const Int_t h = TMath::Min(H, 576); 79 80 memset(fImg, 0, 768*576); 81 for (int y=0; y<h; y++) 82 for (int x=0; x<w; x++) 83 { 84 const Int_t p = (x+y*W)*depth; 85 fImg[x+y*768] = ((UInt_t)img[p]+(UInt_t)img[p+1]+(UInt_t)img[p+2])/3; 86 } 87 } 63 #if 0 64 unsigned char *dest = fImg; 65 for (const unsigned char *ptr=img; ptr<img+768*576*4; ptr+=4) 66 *dest++ = (UShort_t(ptr[1])+UShort_t(ptr[2])+UShort_t(ptr[3]))/3; 67 #endif 88 68 89 69 fClient.ProcessFrame(fNumFrame-1, (byte*)fImg, &fTime); … … 97 77 if (!fVideo->IsOpen()) 98 78 { 99 gLog << err<< "Camera::Thread: ERROR - Device not open." << endl;79 cout << "Camera::Thread: ERROR - Device not open." << endl; 100 80 return kFALSE; 101 81 } 102 82 103 gLog << dbg<< "Start Camera::Thread at frame " << fNumFrame%fVideo->GetNumBuffers() << endl;83 cout << "Start Camera::Thread at frame " << fNumFrame%fVideo->GetNumBuffers() << endl; 104 84 105 85 for (int f=0; f<fVideo->GetNumBuffers(); f++) 86 { 106 87 if (!fVideo->CaptureStart(f)) 107 88 return kFALSE; 89 } 90 91 if (!fVideo->Start()) 92 return kFALSE; 108 93 109 94 Int_t timeouts = 0; 110 95 while (1) 111 96 { 97 98 /* 112 99 // Switch channel if necessary 113 100 switch (fVideo->SetChannel(fChannel)) … … 126 113 return kFALSE; 127 114 break; 128 } 115 }*/ 116 117 //cout << "*** Wait " << fNumFrame << endl; 129 118 130 119 // Check and wait until capture into the next buffer is finshed 131 120 unsigned char *img = 0; 132 switch (fVideo->CaptureWait(fNumFrame ++, &img))121 switch (fVideo->CaptureWait(fNumFrame, &img)) 133 122 { 134 123 case kTRUE: // Process frame … … 145 134 break; 146 135 136 fNumFrame++; 147 137 timeouts = 0; 148 138 continue; … … 151 141 break; 152 142 153 case kSKIP: // Skip frame 143 case -1: // Skip frame 144 usleep(10000); // Wait half a frame 145 continue; 146 154 147 fNumFrame--; 155 148 fNumSkipped++; -
trunk/FACT++/drive/Camera.h
r18618 r18626 5 5 #include "MThread.h" 6 6 #endif 7 7 /* 8 8 #ifndef COSY_PixGetter 9 9 #include "PixGetter.h" 10 10 #endif 11 11 */ 12 12 class MVideo; 13 13 class PixClient; 14 14 15 class Camera : public PixGetter,public MThread15 class Camera : /*public PixGetter,*/ public MThread 16 16 { 17 17 private: … … 21 21 static const int cols = 768; 22 22 static const int rows = 576; 23 static const int depth = 3;23 static const int depth = 4; 24 24 25 char fImg[cols*rows];25 unsigned char fImg[cols*rows]; 26 26 struct timeval fTime; 27 27
Note:
See TracChangeset
for help on using the changeset viewer.