Into

Modules

Documentation

classPiiCameraDriver

#include <PiiCameraDriver.h>

A common interface for cameras that read images into a frame buffer.

Inherits QObject

Inherited by PiiMultiCamDriver

Description

Images are stored as frames containing at least one scan line. Valid frame sizes are determined by the type of camera and the driver.

Frames are captured by initiating a capture sequence by startCapture(). Whenever a new frame is ready, the driver invokes the frameCaptured() function of a registered listener.

PiiCameraDriver is designed to suit the needs detailed in the paragraphs below (and hopefully others).

On-line video via DMA

This type of capture is used by IEEE 1394 (FireWire) cameras and many frame grabbers. The interface card works as a bus master and transfers image data to memory without interrupting the CPU. The term "on-line" refers to a situation in which image frames are requested one by one, and the driver uses a single frame buffer to capture the frames. The driver provides a way to take snapshots of the video whenever needed. It also works in "push" mode in which new frames are written into the frame buffer all the time. The receiving program is signalled after each completed frame.

High-speed cameras

The speed of a camera is said to be high if image data cannot be processed or stored into a hard drive at the original frame rate. In such situations, the driver allocates a larger frame buffer in which it can store many consequent frames. The buffer can also work in a circular fashion: once it is full, the next frame will be stored at the beginning again.

Line-scan cameras

Line-scan capture is a combination of high-speed and ordinary DMA capture. The driver allocates a circularly accessed frame buffer into which scan-lines are read. Each frame is just one pixel high. Although the data is usually analyzed in real time, line-scan drivers can also be used in high-speed mode to capture just a predefined number of frames.

Non-DMA devices

Some devices, such as web cameras and some analog frame grabbers, are not capable of DMA transfers. It is up to the camera driver implementation to allocate space for storage and to keep it sufficiently large not to drop frames.

Accessing frame buffers

By default, the memory for image storage is managed by the driver. With DMA devices, this is often (but not necessarily) the only option. The frame buffer can be accessed either directly or by copying its contents. Direct access is faster, but care must be taken to ensure proper mutual exclusion. To directly access the frame buffer memory, use the frameBuffer() function.

Classes

class

A listener that receives image capture events.

Properties

int
int
int

Public types

enum
{ SoftwareTrigger, HardwareTrigger }

Constructors and destructor

Public member functions

virtual int
( )  = 0

Returns bits per pixel.

virtual QStringList
( )  = 0

Returns a list of the cameras that can be automatically detected by the driver.

virtual int

Returns camera type.

virtual bool
( )  = 0

Closes an initialized driver.

virtual void *
(
  • int frameIndex = 0
)  = 0

Returns a pointer to the beginning of a frame buffer.

virtual QSize
( )  = 0

Returns frame size.

virtual int
( )  = 0

Returns image format.

virtual void
( )  = 0

Initializes the driver.

virtual bool
( )  = 0

Returns true if frames are currently being captured and false otherwise.

virtual bool
( )  = 0

Returns true if the driver is open and false otherwise.

virtual Listener *
( )

Returns the current listener or 0 if there is no listener.

virtual QVariant
(
  • const char * name
)
QVariantMap &

Returns the reference to the map where is all critical properties.

virtual bool
(
  • const char * name
)

Returns true if the driver must be initialized again when setting the property named as 'name'.

virtual QSize
( )  = 0

Returns resolution.

virtual bool
(
  • const QSize & frameSize
)  = 0

Sets frame size.

virtual bool
(
  • int format
)  = 0

Set image format.

virtual void
( )

Sets the listener that handles received image frames.

virtual bool
(
  • const char * name
  • const QVariant & value
)
virtual bool
(
  • TriggerMode mode
)  = 0

Sets the trigger mode.

virtual bool
(
  • int frames = 0
)  = 0

Starts capturing frames.

virtual bool
( )  = 0

Stops capturing frames.

virtual bool
( )  = 0

Tells to the driver that the next image must be triggered now.

virtual TriggerMode
( )  = 0

Returns the trigger mode.

Property details

  • int bitsPerPixel

    [read]
  • int cameraType

    [read]
  • QSize frameSize

    [read, write]
  • int imageFormat

    [read, write]
  • QSize resolution

    [read]

Enumeration details

  • enum TriggerMode

Function details

  • PiiCameraDriver

    ()
  • ~PiiCameraDriver

    ()
  • virtual int bitsPerPixel

    ()
    [pure virtual]

    Returns bits per pixel.

  • virtual QStringList cameraList

    ()
    [pure virtual]

    Returns a list of the cameras that can be automatically detected by the driver.

    Note that this is not necessarily a complete list of accessible cameras. The IDs on the list can be used as the cameraId parameter to the initialize().

  • virtual int cameraType

    ()
    [virtual]

    Returns camera type.

    Default implementation returns PiiCamera::AreaScan.

  • virtual bool close

    ()
    [pure virtual]

    Closes an initialized driver.

    After close(), initialize() must be called again before the driver is functional.

    Returns

    true on success, false otherwise

  • virtual void * frameBuffer

    (
    • int frameIndex = 0
    )
    [pure virtual]

    Returns a pointer to the beginning of a frame buffer.

    Parameters
    frameIndex

    the index of the frame buffer

    Returns

    the frame buffer's memory address

  • virtual QSize frameSize

    ()
    [pure virtual]

    Returns frame size.

  • virtual int imageFormat

    ()
    [pure virtual]

    Returns image format.

  • virtual void initialize

    ()
    [pure virtual]

    Initializes the driver.

    This function is called before frames are being captured. The driver implementation may now initialize DMA buffers, connect to a camera etc.

    The driver may be able to handle many cameras. The active unit is selected by a generic camera id. With frame grabbers, the camera id is typically just a zero-based numerical unit index. Other possibilities include, for example, network addresses. The cameraList() function returns a list of automatically found camera IDs.

    You can configure camera driver via properties, but sometimes you must call initialize(cameraId) again before your configuration value is updated.

    Exceptions
    PiiCameraDriverException&

    if the initialization could not be performed.

  • virtual bool isCapturing

    ()
    [pure virtual]

    Returns true if frames are currently being captured and false otherwise.

  • virtual bool isOpen

    ()
    [pure virtual]

    Returns true if the driver is open and false otherwise.

  • virtual Listener * listener

    ()
    [virtual]

    Returns the current listener or 0 if there is no listener.

  • virtual QVariant property

    (
    • const char * name
    )
    [virtual]
  • QVariantMap & propertyMap

    ()

    Returns the reference to the map where is all critical properties.

  • virtual bool requiresInitialization

    (
    • const char * name
    )
    [virtual]

    Returns true if the driver must be initialized again when setting the property named as 'name'.

    The default implementation returns false.

  • virtual QSize resolution

    ()
    [pure virtual]

    Returns resolution.

  • virtual bool setFrameSize

    (
    • const QSize & frameSize
    )
    [pure virtual]

    Sets frame size.

    Default implementation does nothing.

  • virtual bool setImageFormat

    (
    • int format
    )
    [pure virtual]

    Set image format.

    Default implementation does nothing.

  • virtual void setListener

    ()
    [virtual]

    Sets the listener that handles received image frames.

  • virtual bool setProperty

    (
    • const char * name
    • const QVariant & value
    )
    [virtual]
  • virtual bool setTriggerMode

    (
    • TriggerMode mode
    )
    [pure virtual]

    Sets the trigger mode.

  • virtual bool startCapture

    (
    • int frames = 0
    )
    [pure virtual]

    Starts capturing frames.

    Parameters
    frames

    the maximum number of frames to capture. If this value is less than one, frames will be captured until explicitly interrupted.

    Returns

    true if the capture was successfully started, false otherwise

  • virtual bool stopCapture

    ()
    [pure virtual]

    Stops capturing frames.

    Returns

    true if the capture was successfully stopped, false otherwise.

  • virtual bool triggerImage

    ()
    [pure virtual]

    Tells to the driver that the next image must be triggered now.

  • virtual TriggerMode triggerMode

    ()
    [pure virtual]

    Returns the trigger mode.

Notes (0)

Add a note

Not a single note added yet. Be the first, add yours.