Einzelnen Beitrag anzeigen

BoolString

Registriert seit: 2. Feb 2009
Ort: Varel
70 Beiträge
 
RAD-Studio 2009 Pro
 
#11

AW: Ansprechen einer GigE Kamera (Prosilica GC2450C)

  Alt 17. Jul 2012, 10:14
Theoretisch hätte mir das wohl klar sein sollen; aber praktisch...

Ich hab zumindest über das Wocheende ein wenig weiter dran gearbeitet und komme inzwischen auch an diverse Attribute der Kamera heran.

Ich kann die Kamera inzwischen auch sauber öffnen. Allerdings bekomme ich dabei den PermittedAccess Status 6 zurückgeliefert. Laut SDK Unterlagen sollen aber nur die Statuswerte 2 und 4 (und nicht deren addierte Bitsumme) valide sein. Was könnte das denn wohl bedeuten?

Ich glaube, daß ich schon ein großes Stück weiter bin. Habe mir aus diversen C-Samples jetzt etwas zusammengebastelt. Das muss alles noch in einzelne Procs/Funcs ausgelagert werden, aber für eine Version zum Debuggen ist es ganz praktisch. Derzeit hängt es aber an der Struktur des pFrame (?). Ich versuche das so ähnlich zu machen wie in den C-Samples und im Quellcode, den horst0815 gepostet hat. aber hier stimt irgendwas noch nicht. Ich komme derzeit an kein Bild. Der PvCaptureQueueFrame wirft eine Exception, die ich nicht richtig verfolgt bekomme.

Ich habe derzeit die Header-Datei folgendermassen übersetzt (Ausschnitte):
Delphi-Quellcode:
  tPvImageFormat =
      (ePvFmtMono8 = 0, // Monochrome, 8 bits
        ePvFmtMono16 = 1, // Monochrome, 16 bits, data is LSB aligned
        ePvFmtBayer8 = 2, // Bayer-color, 8 bits
        ePvFmtBayer16 = 3, // Bayer-color, 16 bits, data is LSB aligned
        ePvFmtRgb24 = 4, // RGB, 8 bits x 3
        ePvFmtRgb48 = 5, // RGB, 16 bits x 3, data is LSB aligned
        ePvFmtYuv411 = 6, // YUV 411
        ePvFmtYuv422 = 7, // YUV 422
        ePvFmtYuv444 = 8, // YUV 444
        ePvFmtBgr24 = 9, // BGR, 8 bits x 3
        ePvFmtRgba32 = 10, // RGBA, 8 bits x 4
        ePvFmtBgra32 = 11, // BGRA, 8 bits x 4
        ePvFmtMono12Packed = 12, // Monochrome, 12 bits,
        ePvFmtBayer12Packed = 13, // Bayer-color, 12 bits, packed
        __ePvFmt_force_32 = $FFFFFFFF
       );


//
// Bayer pattern. Applicable when a Bayer-color camera is sending raw bayer
// data.
//
  tPvBayerPattern =
      (ePvBayerRGGB = 0, // First line RGRG, second line GBGB...
       ePvBayerGBRG = 1, // First line GBGB, second line RGRG...
        ePvBayerGRBG = 2, // First line GRGR, second line BGBG...
       ePvBayerBGGR = 3, // First line BGBG, second line GRGR...
       __ePvBayer_force_32 = $FFFFFFFF
       );


  tPvFrame = Packed Record
               //----- In -----
                ImageBuffer : Pointer; // Buffer for image/pixel data.
               ImageBufferSize : Cardinal; // Size of ImageBuffer in bytes
               AncillaryBuffer : Pointer; // Camera Firmware >= 1.42 Only.
                                                                              // Buffer to capture ancillary chunk mode data. See ChunkModeActive attr.
                                                                   // This MUST be 0 if not in use.
                                                                              // Chunk mode format:
                                                                              // [Bytes 1 - 4] acquisition count.
                                                                              // [Bytes 5 - 8] user value. Not currently implemented. 0.
                                                                              //    [Bytes 9 - 12] exposure value.
                                                                   //    [Bytes 13 - 16] gain value.
                                                                              //    [Bytes 17 - 18] sync in levels.
                                                                   //    [Bytes 19 - 20] sync out levels.
                                                                              //    [Bytes 21 - 40] not implemented. 0.
                                                                   //    [Bytes 41 - 44] chunk ID. 1000.
                                                                              //    [Bytes 45 - 48] chunk length.
                AncillaryBufferSize : Cardinal; // Size of your ancillary buffer in bytes. See NonImagePayloadSize attr.
                                                                   // Set to 0 for no buffer.
               Context : Array [0..3] of Pointer; // For your use. Possible application: unique ID
                                                                              // of tPvFrame for frame-done callback.
               _reserved1 : Array [0..7] of Cardinal;
                //----- Out -----
               Status : tPvErr; // Status of this frame
                ImageSize : Cardinal; // Image size, in bytes
               AncillarySize : Cardinal; // Ancillary data size, in bytes
               Width : Cardinal; // Image width
               Height : Cardinal; // Image height
                RegionX : Cardinal; // Start of readout region (left)
                RegionY : Cardinal; // Start of readout region (top)
                Format : tPvImageFormat; // Image format
               BitDepth : Cardinal; // Number of significant bits
                BayerPattern : tPvBayerPattern; // Bayer pattern, if bayer format
                FrameCount : Cardinal; // Frame counter. Uses 16bit GigEVision BlockID. Rolls at 65535.
                TimestampLo : Cardinal; // Time stamp, lower 32-bits
                TimestampHi : Cardinal; // Time stamp, upper 32-bits
               _reserved2 : Array [0..31] of Cardinal;
             end;



  tPvCameraInfoExList = array of tPvCameraInfoEx;
  pPvCameraInfoExList = ^tPvCameraInfoExList;
  tConnectedCams = Cardinal;
  pConnectedCams = ^tConnectedCams;
  pPvFrame = ^tPvFrame;


Const PVINFINITE = $FFFFFFFF; // Never timeout


//-------------------------------------------------------------------------------------
// define DLL-calls:
    Function PvAttrEnumSet (pCamera: tPvHandle; Name: PAnsiChar; Value: PAnsiChar): tPvErr; stdcall; external 'PvAPI.dll';
    Function PvAttrUint32Get (pCamera: tPvHandle; Name: PAnsiChar; Out pValue: Cardinal) : tPvErr; stdcall; external 'PvAPI.dll';
    Function PvCameraListEx (pList: pPvCameraInfoExList; ListLength : Cardinal; Out ConnectedNum : tConnectedCams; Size : Cardinal) : Cardinal; stdcall; external 'PvAPI.dll';
    Function PvCameraClose (pCamera: tPvHandle) : tPvErr; stdcall; external 'PvAPI.dll';
    Function PvCameraOpen (UniqueID: Cardinal; AccessFlag: tPvAccessFlags; Out pCamera: tPvHandle) : tPvErr; stdcall; external 'PvAPI.dll';
    Function PvCaptureStart (pCamera: tPvHandle) : tPvErr; stdcall; external 'PvAPI.dll';
    Function PvCaptureQueueFrame (pCamera: tPvHandle; pFrame: pPvFrame; FrameCallBack: Pointer ): tPvErr; stdcall; external 'PvAPI.dll';
    Function PvCaptureWaitForFrameDone (pCamera: tPvHandle; pFrame: pPvFrame; Timeout: Cardinal): tPvErr; stdcall; external 'PvAPI.dll';
    Function PvCommandRun (pCamera: tPvHandle; Name : PAnsiChar): tPvErr; stdcall; external 'PvAPI.dll';
    Function PvInitialize : tPvErr; stdcall; external 'PvAPI.dll';
    Function PvInitializeNoDiscovery : tPvErr; stdcall; external 'PvAPI.dll';
    Procedure PvUnInitialize; stdcall; external 'PvAPI.dll';
    Procedure PvVersion (Var Major, Minor: Cardinal); stdcall; external 'PvAPI.dll';
Auf der anderen seite steckt erst einmal alles in einem ButtonClick:

Delphi-Quellcode:
procedure TForm1.Button6Click(Sender: TObject);
Var aFrame : tPvFrame;
    aFrameBuffer : Array of Byte;
    aBitMap : tBitmap;
    aErrValue : tPvErr;

Begin
  aErrValue := PvAttrUint32Get (CamHandle, 'TotalBytesPerFrame', aFrame.ImageBufferSize);
  If aErrValue = ePvErrSuccess then
  Begin
    SetLength (aFrameBuffer, aFrame.ImageBufferSize);
    aFrame.ImageBuffer := @aFrameBuffer[0];
  end
  Else
  Begin
    Exit;
  end;

  aErrValue := PvCaptureStart (CamHandle);
  If aErrValue = ePvErrSuccess THen
  Begin

    aErrValue := PvAttrEnumSet (CamHandle, 'FrameStartTriggerMode', 'Freerun');
    If aErrValue = ePvErrSuccess Then
    Begin

      aErrValue := PvCommandRun (CamHandle, 'AcquisitionStart');
      If aErrValue = ePvErrSuccess Then
      Begin

        aErrValue := PvCaptureQueueFrame (CamHandle, @aFrame, 0) ;
        If aErrValue = ePvErrSuccess Then
        Begin

          aErrValue := PvCaptureWaitForFrameDone (CamHandle, @aFrame, PVINFINITE);
          If aErrValue = ePvErrSuccess Then
          Begin
// CreateDIBitmap (@aBitmap,...?????)
            Beep;Beep;Beep;
          end;

        end;
      end;

    end;


  end;
end;
Soweit ich es der SDK-Doku entnehme sollte so eine Aufrufreihenfolge zum Erfolg führen. Aber momentan ist dem noch nicht so...

Jan

PS: Was sind denn wohl erfahrungsgemäß gute Werte für ein TimeOut der Kamera im Debugmodus?
  Mit Zitat antworten Zitat