Changeset 18626


Ignore:
Timestamp:
09/18/16 14:52:24 (8 years ago)
Author:
tbretz
Message:
Removed base class PixGetter, use unsigned char as base type for image and a depth of 4 byte, disentengle from root were possible, some minor cleanup
Location:
trunk/FACT++/drive
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/drive/Camera.cc

    r18618 r18626  
    2424#include "Camera.h"
    2525
    26 #include "MLog.h"
    27 #include "MLogManip.h"
     26#include <iostream>
    2827
    2928#include "MVideo.h"
    3029#include "PixClient.h"
    31 
    32 //ClassImp(Camera);
    3330
    3431using namespace std;
     
    5552    gettimeofday(&fTime, NULL);
    5653
    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
    6162
    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
    8868
    8969    fClient.ProcessFrame(fNumFrame-1, (byte*)fImg, &fTime);
     
    9777    if (!fVideo->IsOpen())
    9878    {
    99         gLog << err << "Camera::Thread: ERROR - Device not open." << endl;
     79        cout << "Camera::Thread: ERROR - Device not open." << endl;
    10080        return kFALSE;
    10181    }
    10282
    103     gLog << dbg << "Start Camera::Thread at frame " << fNumFrame%fVideo->GetNumBuffers() << endl;
     83    cout << "Start Camera::Thread at frame " << fNumFrame%fVideo->GetNumBuffers() << endl;
    10484
    10585    for (int f=0; f<fVideo->GetNumBuffers(); f++)
     86    {
    10687        if (!fVideo->CaptureStart(f))
    10788            return kFALSE;
     89    }
     90
     91    if (!fVideo->Start())
     92        return kFALSE;
    10893
    10994    Int_t timeouts = 0;
    11095    while (1)
    11196    {
     97
     98        /*
    11299        // Switch channel if necessary
    113100        switch (fVideo->SetChannel(fChannel))
     
    126113                    return kFALSE;
    127114            break;
    128         }
     115        }*/
     116
     117        //cout << "*** Wait " << fNumFrame << endl;
    129118
    130119        // Check and wait until capture into the next buffer is finshed
    131120        unsigned char *img = 0;
    132         switch (fVideo->CaptureWait(fNumFrame++, &img))
     121        switch (fVideo->CaptureWait(fNumFrame, &img))
    133122        {
    134123        case kTRUE: // Process frame
     
    145134                break;
    146135
     136            fNumFrame++;
    147137            timeouts = 0;
    148138            continue;
     
    151141            break;
    152142
    153         case kSKIP:  // Skip frame
     143        case -1:  // Skip frame
     144            usleep(10000); // Wait half a frame
     145            continue;
     146
    154147            fNumFrame--;
    155148            fNumSkipped++;
  • trunk/FACT++/drive/Camera.h

    r18618 r18626  
    55#include "MThread.h"
    66#endif
    7 
     7/*
    88#ifndef COSY_PixGetter
    99#include "PixGetter.h"
    1010#endif
    11 
     11*/
    1212class MVideo;
    1313class PixClient;
    1414
    15 class Camera : public PixGetter, public MThread
     15class Camera : /*public PixGetter,*/ public MThread
    1616{
    1717private:
     
    2121    static const int cols  = 768;
    2222    static const int rows  = 576;
    23     static const int depth = 3;
     23    static const int depth = 4;
    2424
    25     char fImg[cols*rows];
     25    unsigned char fImg[cols*rows];
    2626    struct timeval fTime;
    2727
Note: See TracChangeset for help on using the changeset viewer.