Changeset 8860 for trunk/MagicSoft/Cosy
- Timestamp:
- 02/09/08 19:08:26 (17 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r8859 r8860 1 1 -*-*- END -*-*- 2 3 2008/02/09 Thomas Bretz (La Palma) 4 5 * Makefile: 6 - removed readcam 7 8 * cosy.cc: 9 - fixed a problem with the --channel option 10 11 * videodev/Camera.[h,cc]: 12 - changed argument of Process frame to unsigned 13 - always interpolate the rgb value -- this gives clearly 14 less noisy pictures 15 - fixed the switchibng of the channel 16 17 * videodev/PngReader.cc: 18 - fixed order of includes 19 20 2 21 3 22 2008/02/08 Thomas Bretz (La Palma) -
trunk/MagicSoft/Cosy/Makefile
r8845 r8860 19 19 20 20 # 21 PROGRAMS = cosy readcamtelesto21 PROGRAMS = cosy telesto 22 22 SOLIB = libcosy.so 23 23 CINT = M -
trunk/MagicSoft/Cosy/cosy.cc
r8856 r8860 80 80 } 81 81 82 const Int_t channel = arg.GetIntAndRemove("--channel ", 0);82 const Int_t channel = arg.GetIntAndRemove("--channel=", 0); 83 83 const Bool_t kDebugMem = arg.HasOnlyAndRemove("--debug-mem"); 84 84 const Bool_t kDebugThreads = arg.HasOnlyAndRemove("--debug-threads"); -
trunk/MagicSoft/Cosy/videodev/Camera.cc
r8859 r8860 34 34 using namespace std; 35 35 36 Camera::Camera(PixClient &client, Int_t nch) : MThread("Camera"), fClient(client), fVideo(0) 36 Camera::Camera(PixClient &client, Int_t nch) : MThread("Camera"), fClient(client), fVideo(0), fNumFrame(0) 37 37 { 38 38 fVideo = new MVideo; … … 51 51 } 52 52 53 void Camera::ProcessFrame( char *img)53 void Camera::ProcessFrame(unsigned char *img) 54 54 { 55 55 gettimeofday(&fTime, NULL); … … 57 57 const Int_t W = fVideo->GetWidth(); 58 58 const Int_t H = fVideo->GetHeight(); 59 59 /* 60 60 const Bool_t crop = W!=768 || H!=576; 61 61 … … 64 64 { 65 65 // FIXME: Grey scale assumed! 66 const char *end = img + 768*576*depth;66 const unsigned char *end = img + 768*576*depth; 67 67 char *beg = fImg; 68 68 while (img < end) … … 73 73 } 74 74 else 75 */ 75 76 { 76 77 const Int_t w = TMath::Min(W, 768); … … 80 81 for (int y=0; y<h; y++) 81 82 for (int x=0; x<w; x++) 82 fImg[x+y*768] = ((UInt_t)(UChar_t)img[(x+y*W)*3]+(UInt_t)(UChar_t)img[(x+y*fVideo->GetWidth())*3+1]+(UInt_t)(UChar_t)img[(x+y*fVideo->GetWidth())*3+2])/3; 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 } 83 87 } 84 88 … … 97 101 } 98 102 99 //Print();103 gLog << dbg << "Start Camera::Thread at frame " << fNumFrame%fVideo->GetNumBuffers() << endl; 100 104 101 for (int f= 1; f<fVideo->GetNumBuffers(); f++)105 for (int f=0; f<fVideo->GetNumBuffers(); f++) 102 106 if (!fVideo->CaptureStart(f)) 103 107 return kFALSE; 104 108 105 109 Int_t timeouts = 0; 106 107 110 while (1) 108 111 { 109 // If cacellation is requested cancel here 110 TThread::CancelPoint(); 111 112 // Start to capture into the buffer which has just been processed 113 if (!fVideo->CaptureStart(fNumFrame)) 112 // Switch channel if necessary 113 switch (fVideo->SetChannel(fChannel)) 114 { 115 case kFALSE: // Error swucthing channel 116 return kFALSE; 117 case kSKIP: // No channel switching necessary 114 118 break; 115 116 // If cacellation is requested cancel here 117 TThread::CancelPoint(); 119 case kTRUE: // Channel switched (skip filled buffers) 120 for (int f=0; f<fVideo->GetNumBuffers(); f++) 121 if (!fVideo->CaptureWait(fNumFrame+f)) 122 return kFALSE; 123 fNumFrame=0; 124 for (int f=0; f<fVideo->GetNumBuffers(); f++) 125 if (!fVideo->CaptureStart(f)) 126 return kFALSE; 127 break; 128 } 118 129 119 130 // Check and wait until capture into the next buffer is finshed 120 char *img = 0;121 switch (fVideo->CaptureWait( ++fNumFrame, &img))131 unsigned char *img = 0; 132 switch (fVideo->CaptureWait(fNumFrame++, &img)) 122 133 { 123 134 case kTRUE: // Process frame 135 // If cacellation is requested cancel here 136 TThread::CancelPoint(); 137 124 138 ProcessFrame(img); 139 140 // If cacellation is requested cancel here 141 TThread::CancelPoint(); 142 143 // Start to capture into the buffer which has just been processed 144 if (!fVideo->CaptureStart(fNumFrame-1)) 145 break; 146 125 147 timeouts = 0; 126 148 continue; … … 158 180 void Camera::SetChannel(int chan) 159 181 { 160 CancelThread(); 161 fVideo->SetChannel(chan); 162 RunThread(); 182 fChannel = chan; 183 // CancelThread(); 184 // fVideo->SetChannel(chan); 185 // RunThread(); 163 186 } 164 187 -
trunk/MagicSoft/Cosy/videodev/Camera.h
r8859 r8860 33 33 UInt_t fNumSkipped; 34 34 35 UInt_t fChannel; 36 35 37 Int_t Thread(); 36 void ProcessFrame( char *img);38 void ProcessFrame(unsigned char *img); 37 39 38 40 public: -
trunk/MagicSoft/Cosy/videodev/PngReader.cc
r8859 r8860 1 #include "png.h" 2 1 3 #include "PngReader.h" 2 #include "PixClient.h"3 4 4 5 #include <iostream> 5 #include <stdio.h>6 #include <stdlib.h>7 #include <errno.h>8 #include <fcntl.h>9 #include <string.h>10 #include <signal.h>11 #include <endian.h>12 #include <sys/ioctl.h>13 #include <sys/mman.h>14 #include <sys/ipc.h>15 #include <sys/shm.h>16 6 17 #include "png.h" 18 19 #include "videodev.h" 20 21 #include <sys/time.h> 22 #include <sys/resource.h> 7 #include "PixClient.h" 23 8 24 9 ClassImp(PngReader);
Note:
See TracChangeset
for help on using the changeset viewer.