Into

Modules

Documentation

classPiiCameraOperation

#include <PiiCameraOperation.h>

PiiCameraOperation description.

Inherits PiiImageReaderOperation, PiiCameraDriver::Listener

Description

Properties

The ID of the selected camera.

A list of available camera IDs.

bool

If this property is true, the operation will make a deep copy of each captured frame.

The name of the camera driver to be used.

bool

If this property is true, the operation doesn't try convert the grabbed image automatically.

Public Slots

bool

Loads the camera configuration from file.

bool

Saves the camera configuration into file.

Constructors and destructor

(
  • Data * data
)

Public member functions

virtual void
( )

Called when an error occurs while capturing images.

virtual void

Called just after the driver has stopped capturing frames.

virtual void
(
  • bool reset
)

Checks the operation for execution.

virtual void
(
  • int frameIndex
  • void * frameBuffer
  • qint64 elapsedTime
)

Called whenever when a frame has been captured.

virtual void
(
  • int startIndex
  • int endIndex
)

Called when the driver notices that the receiver cannot process all frames.

virtual void

Interrupts the processor.

virtual void
( )

Prepares the operation for pausing.

virtual QVariant
(
  • const char * name
)

Acquires processLock() for reading and returns the property.

template<class Archive>
void
(
  • Archive & archive
  • const unsigned int
)
virtual bool
(
  • const char * name
  • const QVariant & value
)

Ensures that no property will be set while process() or syncEvent() is being called by acquiring processLock() for writing.

void
(
  • bool useRawImage
)
virtual void
( )

Starts the processor.

virtual void
( )

Prepares the operation for stopping.

bool

Protected member functions

bool
( )
(
  • Data * data
)
virtual void

Executes one round of processing.

virtual PiiVariant
(
  • const PiiVariant & image
  • int frameIndex
  • qint64 elapsedTime
)

Processes an image before delivery.

void
( )
void
(
  • bool copy
)
void
( )

Friends

friend struct

Property details

  • QString cameraId

    [read, write]

    The ID of the selected camera.

    A list of selectable cameras can be read from cameraList. The ID of a camera can be any string. For example, IP camera drivers use a URL to identify the camera.

  • QStringList cameraList

    [read]

    A list of available camera IDs.

    Note that not all camera drivers provide a camera list. In such cases, the cameraId property must be set according to the camera driver. Some drivers provide a list of accessible cameras, but still support other cameras as well.

  • bool copyImage

    [read, write]

    If this property is true, the operation will make a deep copy of each captured frame.

    Otherwise, it is up to the driver how the memory is allocated. This mode is usually faster. However, drivers that use a circular frame buffer, will silently overwrite image data if the frame buffer is not big enough. The default value is false.

  • QString driverName

    [read, write]

    The name of the camera driver to be used.

    If the driver is not available, the operation will fail to start.

  • PII_DECLARE_VIRTUAL_METAOBJECT_FUNCTION

  • bool useRawImage

    [read, write]

    If this property is true, the operation doesn't try convert the grabbed image automatically.

    It only send the raw image forward. The default value is false.

Function details

  • PiiCameraOperation

    ()
  • PiiCameraOperation

    (
    • Data * data
    )
    [protected]
  • ~PiiCameraOperation

    ()
  • virtual void captureError

    ( )
    [virtual]

    Called when an error occurs while capturing images.

    Parameters
    message

    a description of the error

    Reimplemented from PiiCameraDriver::Listener.

  • virtual void captureFinished

    ()
    [virtual]

    Called just after the driver has stopped capturing frames.

    Reimplemented from PiiCameraDriver::Listener.

  • virtual void check

    (
    • bool reset
    )
    [virtual]

    Checks the operation for execution.

    This function creates a suitable flow controller by calling createFlowController(). It then sets the flow controller to the active processor and sets the processor as the input controller for all inputs.

    If you change socket groupings in your overridden implementation, please call PiiDefaultOperation::check() after that. Otherwise, your new groupings will not be in effect.

    Reimplemented from PiiImageReaderOperation.

  • virtual void frameCaptured

    (
    • int frameIndex
    • void * frameBuffer
    • qint64 elapsedTime
    )
    [virtual]

    Called whenever when a frame has been captured.

    The receiver can perform its image processing tasks here while the driver continues capturing frames.

    Parameters
    frameIndex

    the index of the last captured frame. The frame index is a linear counter that can be used to fetch the frame data from the driver using PiiCameraDriver::frameBuffer().

    frameBuffer

    a pointer to the captured buffer. If frameBuffer is non-zero, a new frame was allocated inside the driver and must be deallocated with free() by the caller.

    elapsedTime

    a time in micro seconds measured from the previous frame. Zero (the default value) means that the driver can't measure the time.

    Reimplemented from PiiCameraDriver::Listener.

  • virtual void framesMissed

    (
    • int startIndex
    • int endIndex
    )
    [virtual]

    Called when the driver notices that the receiver cannot process all frames.

    Depending on the size of the frame buffer the driver may allow the processing lag behind for a while. When it decides the processing will never catch up capture, it'll inform the listener. The next frame sent to frameCaptured() will be after endIndex.

    Missed frames are not necessarily accessible in the driver. Therefore, it is not allowed to call PiiCameraDriver::frameBuffer() for missed frames. Doing so may crash your application, cause a deadlock or anything else. To avoid trouble, it is best not to access the driver from the implementation of this function. You have been warned.

    Parameters
    startIndex

    the first missed frame

    endIndex

    the last missed frame

    Reimplemented from PiiCameraDriver::Listener.

  • virtual void interrupt

    ()
    [virtual]

    Interrupts the processor.

    Does not alter the state of the operation unless the processor does so.

    Reimplemented from PiiDefaultOperation.

  • virtual void pause

    ()
    [virtual]

    Prepares the operation for pausing.

    The functioning is dependent on the type of the processor. In threaded mode, the operation will be turned into Pausing state, and processing will pause once the thread has finished its current processing round. In simple mode, the processor will check if the operation has connected inputs. If it does, the operation will turn into Pausing state and wait until it receives pause signals from previous operations in the pipeline. If there are no connected inputs, the operation will immediately turn into Paused state.

    Reimplemented from PiiDefaultOperation.

  • virtual QVariant property

    (
    • const char * name
    )
    [virtual]

    Acquires processLock() for reading and returns the property.

    Reimplemented from PiiDefaultOperation.

  • template<class Archive>

    void serialize

    (
    • Archive & archive
    • const unsigned int
    )
    [inline]
  • virtual bool setProperty

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

    Ensures that no property will be set while process() or syncEvent() is being called by acquiring processLock() for writing.

    Then sets the property.

    Reimplemented from PiiDefaultOperation.

  • void setUseRawImage

    (
    • bool useRawImage
    )
  • virtual void start

    ()
    [virtual]

    Starts the processor.

    If check() has not been called, this function writes out a warning and returns.

    Reimplemented from PiiDefaultOperation.

  • virtual void stop

    ()
    [virtual]

    Prepares the operation for stopping.

    Works analogously to pause().

    Reimplemented from PiiDefaultOperation.

  • bool useRawImage

    ()
  • QString cameraId

    ()
    [protected]
  • QStringList cameraList

    ()
    [protected]
  • bool copyImage

    ()
    [protected]
  • QObject * driver

    ()
    [protected]
  • QString driverName

    ()
    [protected]
  • virtual void process

    ()
    [protected, virtual]

    Executes one round of processing.

    This function is invoked by the processor if the necessary preconditions for a new processing round are met. This function does all the necessary calculations to create output objects and sends them to output sockets.

    Calls to process(), syncEvent(), and setProperty() are synchronized and cannot occur simultaneously. PiiDefaultOperation ensures this by locking processLock() for reading before calling process().

    Note: With time-consuming operations, one should occasionally check that the operation hasn't been interrupted, i.e. that state() returns Running.

    Exceptions
    PiiExecutionException

    whenever an unrecoverable error occurs during a processing round, the operation is interrupted, or finishes execution due to end of input data.

    Reimplemented from PiiDefaultOperation.

  • virtual PiiVariant processImage

    (
    • const PiiVariant & image
    • int frameIndex
    • qint64 elapsedTime
    )
    [protected, virtual]

    Processes an image before delivery.

    The default implementation returns image. Subclasses may add custom functionality by overriding this function.

  • void setCameraId

    ( )
    [protected]
  • void setCopyImage

    (
    • bool copy
    )
    [protected]
  • void setDriverName

    ( )
    [protected]
  • bool loadCameraConfig

    ()
    [slot]

    Loads the camera configuration from file.

    There might be the configuration values which needs to start the processing again. If no driver has been loaded yet, this function does nothing. Returns true on success, false otherwise.

  • bool saveCameraConfig

    ()
    [slot]

    Saves the camera configuration into file.

    If no driver has been loaded yet, this function does nothing. Returns true on success, false otherwise.

Notes (0)

Add a note

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