Changeset 8860 for trunk


Ignore:
Timestamp:
02/09/08 19:08:26 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Cosy
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Cosy/Changelog

    r8859 r8860  
    11                                                                  -*-*- 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
    221
    322 2008/02/08 Thomas Bretz (La Palma)
  • trunk/MagicSoft/Cosy/Makefile

    r8845 r8860  
    1919
    2020#
    21 PROGRAMS = cosy readcam telesto
     21PROGRAMS = cosy telesto
    2222SOLIB    = libcosy.so
    2323CINT     = M
  • trunk/MagicSoft/Cosy/cosy.cc

    r8856 r8860  
    8080    }
    8181
    82     const Int_t  channel       = arg.GetIntAndRemove("--channel", 0);
     82    const Int_t  channel       = arg.GetIntAndRemove("--channel=", 0);
    8383    const Bool_t kDebugMem     = arg.HasOnlyAndRemove("--debug-mem");
    8484    const Bool_t kDebugThreads = arg.HasOnlyAndRemove("--debug-threads");
  • trunk/MagicSoft/Cosy/videodev/Camera.cc

    r8859 r8860  
    3434using namespace std;
    3535
    36 Camera::Camera(PixClient &client, Int_t nch) : MThread("Camera"), fClient(client), fVideo(0)
     36Camera::Camera(PixClient &client, Int_t nch) : MThread("Camera"), fClient(client), fVideo(0), fNumFrame(0)
    3737{
    3838    fVideo = new MVideo;
     
    5151}
    5252
    53 void Camera::ProcessFrame(char *img)
     53void Camera::ProcessFrame(unsigned char *img)
    5454{
    5555    gettimeofday(&fTime, NULL);
     
    5757    const Int_t W = fVideo->GetWidth();
    5858    const Int_t H = fVideo->GetHeight();
    59 
     59/*
    6060    const Bool_t crop = W!=768 || H!=576;
    6161
     
    6464    {
    6565        // FIXME: Grey scale assumed!
    66         const char *end = img + 768*576*depth;
     66        const unsigned char *end = img + 768*576*depth;
    6767        char *beg = fImg;
    6868        while (img < end)
     
    7373    }
    7474    else
     75 */
    7576    {
    7677        const Int_t w = TMath::Min(W, 768);
     
    8081        for (int y=0; y<h; y++)
    8182            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            }
    8387    }
    8488
     
    97101    }
    98102
    99     //Print();
     103    gLog << dbg << "Start Camera::Thread at frame " << fNumFrame%fVideo->GetNumBuffers() << endl;
    100104
    101     for (int f=1; f<fVideo->GetNumBuffers(); f++)
     105    for (int f=0; f<fVideo->GetNumBuffers(); f++)
    102106        if (!fVideo->CaptureStart(f))
    103107            return kFALSE;
    104108
    105109    Int_t timeouts = 0;
    106 
    107110    while (1)
    108111    {
    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
    114118            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        }
    118129
    119130        // 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))
    122133        {
    123134        case kTRUE: // Process frame
     135            // If cacellation is requested cancel here
     136            TThread::CancelPoint();
     137
    124138            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
    125147            timeouts = 0;
    126148            continue;
     
    158180void Camera::SetChannel(int chan)
    159181{
    160     CancelThread();
    161     fVideo->SetChannel(chan);
    162     RunThread();
     182    fChannel = chan;
     183//    CancelThread();
     184//    fVideo->SetChannel(chan);
     185//    RunThread();
    163186}
    164187
  • trunk/MagicSoft/Cosy/videodev/Camera.h

    r8859 r8860  
    3333    UInt_t fNumSkipped;
    3434
     35    UInt_t fChannel;
     36
    3537    Int_t Thread();
    36     void  ProcessFrame(char *img);
     38    void  ProcessFrame(unsigned char *img);
    3739
    3840public:
  • trunk/MagicSoft/Cosy/videodev/PngReader.cc

    r8859 r8860  
     1#include "png.h"
     2
    13#include "PngReader.h"
    2 #include "PixClient.h"
    34
    45#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>
    166
    17 #include "png.h"
    18 
    19 #include "videodev.h"
    20 
    21 #include <sys/time.h>
    22 #include <sys/resource.h>
     7#include "PixClient.h"
    238
    249ClassImp(PngReader);
Note: See TracChangeset for help on using the changeset viewer.