Ignore:
Timestamp:
02/08/08 22:49:30 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy/videodev
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/videodev/Camera.cc

    r8856 r8859  
    5151}
    5252
    53 void Camera::ExitLoop()
    54 {
    55     CancelThread();
    56 
    57     // Some information
    58     //cout << fNumFrame-1 << "frames processed." << endl;
    59     //cout << fNumSkipped << "frames skipped." << endl;
    60 }
    61 
    6253void Camera::ProcessFrame(char *img)
    6354{
     
    9889{
    9990    fNumSkipped = 0;
    100     fNumFrame   = 1;
     91    fNumFrame   = 0;
    10192
    10293    if (!fVideo->IsOpen())
     
    10899    //Print();
    109100
    110     for (int f=0; f<fVideo->GetNumBuffers()-1; f++)
     101    for (int f=1; f<fVideo->GetNumBuffers(); f++)
    111102        if (!fVideo->CaptureStart(f))
    112103            return kFALSE;
     
    161152}
    162153
    163 void Camera::Loop(unsigned long nof)
    164 {
    165 }
     154//void Camera::Loop(unsigned long nof)
     155//{
     156//}
    166157
    167158void Camera::SetChannel(int chan)
  • trunk/MagicSoft/Cosy/videodev/Camera.h

    r8843 r8859  
    4040    virtual ~Camera();
    4141
    42     //
    43     // Starts, stops the execution
    44     //
    45     void Loop(const unsigned long nof=0);
    46     void ExitLoop();
    47     //int  IsRunning() const;
     42    void SetChannel(int);
    4843
    49     void SetChannel(int);
     44    void ExitLoop() { CancelThread(); }
    5045
    5146    //ClassDef(Camera, 0)
  • trunk/MagicSoft/Cosy/videodev/MVideo.cc

    r8856 r8859  
    263263        fCaps.maxheight, fCaps.maxwidth, // height, width
    264264        VIDEO_PALETTE_RGB24              // palette
    265         //768, 576,
    266         //VIDEO_PALETTE_RGB555             // palette
    267265    };
    268266
     
    274272
    275273//    if (errno == EAGAIN)
    276         gLog << err << "ERROR - Couldn't start capturing frame " << frame << " - unable to sync." << endl;
     274    gLog << err;
     275    gLog << "ERROR - Couldn't start capturing frame " << frame << " - unable to sync." << endl;
     276    gLog << "        Maybe your card doesn't support VIDEO_PALETTE_RGB24." << endl;
    277277
    278278    return kFALSE;
  • trunk/MagicSoft/Cosy/videodev/PngReader.cc

    r8378 r8859  
    113113{
    114114    cout << "Starting thread..." << flush;
    115     pthread_create(&fThread, NULL, MapThread, this);
     115    RunThread();
    116116    cout << "done." << endl;
    117117
     
    121121{
    122122    cout << "Stopping thread..." << flush;
    123     pthread_cancel(fThread);
     123    CancelThread();
    124124    cout << "done." << endl;
    125125}
    126126
    127 void *PngReader::MapThread(void *arg)
     127Int_t PngReader::Thread()
    128128{
    129     PngReader *cam = (PngReader*)arg;
     129    Sleep(3000000);
    130130
    131     // setpriority(PRIO_PROCESS, 0, 10);
    132     pthread_detach(pthread_self());
    133 
    134     cam->Thread();
    135 
    136     return 0;
    137 }
    138 
    139 void PngReader::Thread()
    140 {
    141     fIsRunning = 1;
    142     usleep(3000000);
    143131    int i=0;
    144132
    145133    gettimeofday(&fTime, NULL);
    146134
    147     while (!fStop)
     135    while (1)
    148136    {
    149137        // if (i<536)
    150138        // {
    151139        GetImg(i);
     140
     141        TThread::CancelPoint();
     142
    152143        fClient.ProcessFrame(i++, (byte*)fImg, &fTime);
    153144        // usleep(10000);
     
    155146        // else exit();
    156147        fTime.tv_sec += 1;
    157         usleep(1000);
     148        Sleep(1000);
    158149    }
    159150
    160 
    161     fIsRunning = 0;
     151    return 0;
    162152}
    163153
  • trunk/MagicSoft/Cosy/videodev/PngReader.h

    r2278 r8859  
    1 #ifndef PngReader_H
    2 #define PngReader_H
     1#ifndef COSY_PngReader
     2#define COSY_PngReader
    33
    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>
     4#ifndef MARS_MThread
     5#include "MThread.h"
    146#endif
    157
     8#ifndef COSY_PixGetter
    169#include "PixGetter.h"
     10#endif
    1711
    1812class PixClient;
    1913
    20 typedef unsigned char byte;
    21 
    22 class PngReader : public PixGetter
     14class PngReader : public PixGetter, public MThread
    2315{
    2416private:
     
    3022    static const int gfDepth = 3;
    3123
    32     int fStop;
    33     int fIsRunning;
    34 
    3524    //
    3625    // Thread interface
     
    4029    char fImg[gfCols*gfRows];
    4130    struct timeval fTime;
    42 
    43     pthread_t fThread;
    4431
    4532    PixClient &fClient;
     
    5340    // Execution thread which processes the pictures
    5441    //
    55     void Thread();
    56     static void *MapThread(void *arg);
     42    Int_t Thread();
    5743
    5844public:
     
    6046    virtual ~PngReader();
    6147
    62     //
    63     // Starts, stops the execution
    64     //
    65     void ExitLoop()
    66     {
    67         fStop = 1;
    68         while (IsRunning())
    69             usleep(1);
    70     }
    71 
    72     //
    73     // flag if the execution is running or not
    74     //
    75     int IsRunning() const { return fIsRunning; }
     48    void ExitLoop() { CancelThread(); }
    7649
    7750    ClassDef(PngReader, 0)
Note: See TracChangeset for help on using the changeset viewer.