Halyri - Mobiili  0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
Halyri.AudioVideoManagers.PreviewImageCapturer Class Reference

Class for capturing preview images from AudioVideoCaptureDevice and compressing them to jpeg. Enables the comressed frames to have lower resolution and frame rate than the AudioVideoCaptureDevice preview buffer generates. More...

Public Member Functions

 PreviewImageCapturer (AudioVideoCaptureDevice source)
 Instantializes a new PreviewImageCapturer using the provided AudioVideoCaptureDevice as it's preview image source. This class will not open the AudioVideoCaptureDevice for capture. Before calling StartCapture, the AudioVideoCaptureDevice has to be opened for video or audiovideo capture. More...
 
void StartCapture ()
 Starts capturing preview buffer frames. Before calling StartCapture, the AudioVideoCaptureDevice has to be opened for video or audiovideo capture. More...
 
void StopCapture ()
 Stops listening for preview frames from the AudioVideoCaptureDevice. More...
 
void SetQualityParameters (float fps, int compressionQuality, int compressedWidth, int compressedHeight)
 Sets parameters related to jpeg compression quality, frame capture rate and size of the compressed frame. The captured frame from the preview buffer is scaled to the provided dimensions on compression. More...
 

Public Attributes

JpgFrameCaptured JpgFrameCapturedEvent
 

Properties

float Fps [get, set]
 
double SourceImageRatio [get]
 
int imageWidth [get]
 
int imageHeight [get]
 

Private Member Functions

void captureDevice_PreviewFrameAvailable (ICameraCaptureDevice sender, object args)
 Handles new preview buffer frames from AudioVideoCaptureDevice. This method will be called by the AudioVideoCaptureDevice on every availanle frame, but some of them are skipped to achieve a resulting image frame rate closer to the specified Fps. More...
 
void updateSkipFpsValue ()
 Updates the skipFrames value based on the ratio of the actual fps of the preview buffer and the requested jps image Fps value. More...
 

Private Attributes

int sourceFps = 30
 
float fps
 
int skipFrames
 
int skipFpsCounter
 
int jpgCompressionQualityLow = 0
 
int jpgCompressionQualityHigh = 100
 
int jpgCompressionQuality = 50
 
double sourceWidth
 
double sourceHeight
 
int jpgWidth = 640
 
int jpgHeight = 480
 
Object configurationLock
 
AudioVideoCaptureDevice captureDevice
 
Boolean started
 

Detailed Description

Class for capturing preview images from AudioVideoCaptureDevice and compressing them to jpeg. Enables the comressed frames to have lower resolution and frame rate than the AudioVideoCaptureDevice preview buffer generates.

<author>Veli-Mikko Puupponen</author> TODO: should also count the time between captured frames on the captureDevice_PreviewFrameAvailable. If the AudioVideoCaptureDevice providing the frames starts slowing down, the problem would be detected and the outgoing frame rate wound not drop proportionally.

Constructor & Destructor Documentation

Halyri.AudioVideoManagers.PreviewImageCapturer.PreviewImageCapturer ( AudioVideoCaptureDevice  source)

Instantializes a new PreviewImageCapturer using the provided AudioVideoCaptureDevice as it's preview image source. This class will not open the AudioVideoCaptureDevice for capture. Before calling StartCapture, the AudioVideoCaptureDevice has to be opened for video or audiovideo capture.

Parameters
sourceAudioVideoCaptureDevice to be used as a source of ARGB preview frames

Member Function Documentation

void Halyri.AudioVideoManagers.PreviewImageCapturer.captureDevice_PreviewFrameAvailable ( ICameraCaptureDevice  sender,
object  args 
)
private

Handles new preview buffer frames from AudioVideoCaptureDevice. This method will be called by the AudioVideoCaptureDevice on every availanle frame, but some of them are skipped to achieve a resulting image frame rate closer to the specified Fps.

TODO: should release the configurationLock after reading the configuration but before doing any image processing.

Parameters
senderICameraCaptureDevice publishing the event
argsEvent arguments, not used
void Halyri.AudioVideoManagers.PreviewImageCapturer.SetQualityParameters ( float  fps,
int  compressionQuality,
int  compressedWidth,
int  compressedHeight 
)

Sets parameters related to jpeg compression quality, frame capture rate and size of the compressed frame. The captured frame from the preview buffer is scaled to the provided dimensions on compression.

Parameters
fpsNumber of frames to capture per second
compressionQualityCompression quality for the resulting jpgs, 0 to 100, where 100 is the best quality
compressedWidthWidth of the compressed image. If different from the AudioVideoCaptureDevices preview width, the image will be scaled on compression.
compressedHeightHeight of the compressed image. If different from the AudioVideoCaptureDevices preview height, the image will be scaled on compression.
void Halyri.AudioVideoManagers.PreviewImageCapturer.StartCapture ( )

Starts capturing preview buffer frames. Before calling StartCapture, the AudioVideoCaptureDevice has to be opened for video or audiovideo capture.

void Halyri.AudioVideoManagers.PreviewImageCapturer.StopCapture ( )

Stops listening for preview frames from the AudioVideoCaptureDevice.

void Halyri.AudioVideoManagers.PreviewImageCapturer.updateSkipFpsValue ( )
private

Updates the skipFrames value based on the ratio of the actual fps of the preview buffer and the requested jps image Fps value.

Member Data Documentation

AudioVideoCaptureDevice Halyri.AudioVideoManagers.PreviewImageCapturer.captureDevice
private
Object Halyri.AudioVideoManagers.PreviewImageCapturer.configurationLock
private
float Halyri.AudioVideoManagers.PreviewImageCapturer.fps
private
int Halyri.AudioVideoManagers.PreviewImageCapturer.jpgCompressionQuality = 50
private
int Halyri.AudioVideoManagers.PreviewImageCapturer.jpgCompressionQualityHigh = 100
private
int Halyri.AudioVideoManagers.PreviewImageCapturer.jpgCompressionQualityLow = 0
private
JpgFrameCaptured Halyri.AudioVideoManagers.PreviewImageCapturer.JpgFrameCapturedEvent
int Halyri.AudioVideoManagers.PreviewImageCapturer.jpgHeight = 480
private
int Halyri.AudioVideoManagers.PreviewImageCapturer.jpgWidth = 640
private
int Halyri.AudioVideoManagers.PreviewImageCapturer.skipFpsCounter
private
int Halyri.AudioVideoManagers.PreviewImageCapturer.skipFrames
private
int Halyri.AudioVideoManagers.PreviewImageCapturer.sourceFps = 30
private
double Halyri.AudioVideoManagers.PreviewImageCapturer.sourceHeight
private
double Halyri.AudioVideoManagers.PreviewImageCapturer.sourceWidth
private
Boolean Halyri.AudioVideoManagers.PreviewImageCapturer.started
private

Property Documentation

float Halyri.AudioVideoManagers.PreviewImageCapturer.Fps
getsetprivate
int Halyri.AudioVideoManagers.PreviewImageCapturer.imageHeight
get
int Halyri.AudioVideoManagers.PreviewImageCapturer.imageWidth
get
double Halyri.AudioVideoManagers.PreviewImageCapturer.SourceImageRatio
get

The documentation for this class was generated from the following file: