frameconversions.c File Reference

This file implements various functions to convert frame formats between RGB/BGR and HSV formats. More...

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <linux/videodev.h>
#include <unistd.h>
#include "frametypes.h"
#include "frameconversions.h"
#include "macros.h"

Include dependency graph for frameconversions.c:

Go to the source code of this file.

Defines

#define LOCAL_VAR_Q   ( hsv->value * ( SCALINGCONST - (hsv->saturation * f)/(SCALINGCONST_6) ) ) >> (SCALINGCONSTSIZE+SHIFT2CHAR)
#define LOCAL_VAR_T   ( hsv->value * ( SCALINGCONST - hsv->saturation + (hsv->saturation * f)/(SCALINGCONST_6) ) ) >> (SCALINGCONSTSIZE+SHIFT2CHAR)

Functions

void dhsv2bgr (const dhsv_pixel_t *hsv, bgr_pixel_t *bgr)
 This function converts a HSV pixel (encoded in double values to a BGR pixel.
void fhsv2bgr (const fhsv_pixel_t *hsv, bgr_pixel_t *bgr)
 This function converts a HSV pixel (encoded in float values to a BGR pixel.
void shsv2bgr (const shsv_pixel_t *hsv, bgr_pixel_t *bgr)
 This function converts a HSV pixel (encoded in short int values to a BGR pixel.
void bgr2dhsv (const bgr_pixel_t *bgr, dhsv_pixel_t *hsv)
 This function converts a BGR pixel to a HSV pixel encoded in double values.
void bgr2fhsv (const bgr_pixel_t *bgr, fhsv_pixel_t *hsv)
 This function converts a BGR pixel to a HSV pixel encoded in float values.
void bgr2shsv (const bgr_pixel_t *bgr, shsv_pixel_t *hsv)
 This function converts a BGR pixel to a HSV pixel encoded in short int values.
bgr_frame_tcreate_bgr_frame (int width, int height)
 Creates a new BGR frame and allocates memory for it.
void drop_bgr_frame (bgr_frame_t *frame)
 Clears the frame and frees all allocated memory.
shsv_frame_tcreate_shsv_frame (int width, int height)
 Creates a new HSV frame and allocates memory for it.
void drop_shsv_frame (shsv_frame_t *frame)
 Clears the frame and frees all allocated memory.
int convert_fbframe2bgr (const FRAME *fbframe, bgr_frame_t *bgrf)
 Converts the frame we get from libfg to a BGR frame.
int convert_shsv2bgr (const shsv_frame_t *shsvf, bgr_frame_t *bgrf)
 Converts a HSV frame to BGR frame.
int convert_bgr2shsv (const bgr_frame_t *bgrf, shsv_frame_t *shsvf)
 Converts a BGR frame to HSV frame.
int send_bgr_frame (int fd, const bgr_frame_t *frame)
 Send a BGR frame to the given file descriptor.
int convert_bgr2raw (const bgr_frame_t *frame, char *out)


Detailed Description

This file implements various functions to convert frame formats between RGB/BGR and HSV formats.

Version:
Id
frameconversions.c,v 1.14 2008/09/18 12:59:01 prokop Exp

Definition in file frameconversions.c.


Define Documentation

#define LOCAL_VAR_Q   ( hsv->value * ( SCALINGCONST - (hsv->saturation * f)/(SCALINGCONST_6) ) ) >> (SCALINGCONSTSIZE+SHIFT2CHAR)

#define LOCAL_VAR_T   ( hsv->value * ( SCALINGCONST - hsv->saturation + (hsv->saturation * f)/(SCALINGCONST_6) ) ) >> (SCALINGCONSTSIZE+SHIFT2CHAR)


Function Documentation

void bgr2dhsv ( const bgr_pixel_t bgr,
dhsv_pixel_t hsv 
)

This function converts a BGR pixel to a HSV pixel encoded in double values.

Parameters:
bgr pointer to BGR pixel structure
hsv pointer to HSV pixel structure, which will be overwritten
See also:
http://de.wikipedia.org/wiki/HSV-Farbraum

Definition at line 211 of file frameconversions.c.

void bgr2fhsv ( const bgr_pixel_t bgr,
fhsv_pixel_t hsv 
)

This function converts a BGR pixel to a HSV pixel encoded in float values.

Parameters:
bgr pointer to BGR pixel structure
hsv pointer to HSV pixel structure, which will be overwritten
See also:
http://de.wikipedia.org/wiki/HSV-Farbraum

Definition at line 241 of file frameconversions.c.

void bgr2shsv ( const bgr_pixel_t bgr,
shsv_pixel_t hsv 
) [inline]

This function converts a BGR pixel to a HSV pixel encoded in short int values.

Parameters:
bgr pointer to BGR pixel structure
hsv pointer to HSV pixel structure, which will be overwritten
See also:
http://de.wikipedia.org/wiki/HSV-Farbraum

Definition at line 272 of file frameconversions.c.

int convert_bgr2raw ( const bgr_frame_t frame,
char *  out 
)

Definition at line 483 of file frameconversions.c.

int convert_bgr2shsv ( const bgr_frame_t bgrf,
shsv_frame_t shsvf 
)

Converts a BGR frame to HSV frame.

Parameters:
bgrf Frame in BGR format
shsvf Target frame in HSV format, which has to be the same size as bgrf
Returns:
1 on successful conversion, 0 on error

Definition at line 445 of file frameconversions.c.

int convert_fbframe2bgr ( const FRAME *  fbframe,
bgr_frame_t bgrf 
)

Converts the frame we get from libfg to a BGR frame.

Parameters:
fbframe Frame from libfg
bgrf BGR frame which has to be the same size as fbframe
Returns:
1 on success, 0 on error

Definition at line 367 of file frameconversions.c.

int convert_shsv2bgr ( const shsv_frame_t shsvf,
bgr_frame_t bgrf 
)

Converts a HSV frame to BGR frame.

Parameters:
shsvf Frame in HSV format
bgrf Target frame in BGR format, which has to be the same size as shsvf
Returns:
1 on successful conversion, 0 on error

Definition at line 433 of file frameconversions.c.

bgr_frame_t* create_bgr_frame ( int  width,
int  height 
)

Creates a new BGR frame and allocates memory for it.

Parameters:
width Width of the frame
height Height of the frame
Returns:
pointer to the new frame

Definition at line 313 of file frameconversions.c.

shsv_frame_t* create_shsv_frame ( int  width,
int  height 
)

Creates a new HSV frame and allocates memory for it.

Parameters:
width Width of the frame
height Height of the frame
Returns:
pointer to the new frame

Definition at line 340 of file frameconversions.c.

void dhsv2bgr ( const dhsv_pixel_t hsv,
bgr_pixel_t bgr 
)

This function converts a HSV pixel (encoded in double values to a BGR pixel.

Parameters:
hsv pointer to HSV pixel structure
bgr pointer to BGR pixel structure, which will be overwritten
See also:
http://de.wikipedia.org/wiki/HSV-Farbraum

Definition at line 37 of file frameconversions.c.

void drop_bgr_frame ( bgr_frame_t frame  ) 

Clears the frame and frees all allocated memory.

Parameters:
frame BGR frame to drop

Definition at line 329 of file frameconversions.c.

void drop_shsv_frame ( shsv_frame_t frame  ) 

Clears the frame and frees all allocated memory.

Parameters:
frame HSV frame to drop

Definition at line 356 of file frameconversions.c.

void fhsv2bgr ( const fhsv_pixel_t hsv,
bgr_pixel_t bgr 
)

This function converts a HSV pixel (encoded in float values to a BGR pixel.

Parameters:
hsv pointer to HSV pixel structure
bgr pointer to BGR pixel structure, which will be overwritten
See also:
http://de.wikipedia.org/wiki/HSV-Farbraum

Definition at line 92 of file frameconversions.c.

int send_bgr_frame ( int  fd,
const bgr_frame_t frame 
)

Send a BGR frame to the given file descriptor.

We need it to send the frame over the network.

Parameters:
fd A file descriptor open for writing
frame the BGR frame we want to send
Returns:
Number of sent bytes

Definition at line 457 of file frameconversions.c.

void shsv2bgr ( const shsv_pixel_t hsv,
bgr_pixel_t bgr 
) [inline]

This function converts a HSV pixel (encoded in short int values to a BGR pixel.

Parameters:
hsv pointer to HSV pixel structure
bgr pointer to BGR pixel structure, which will be overwritten
See also:
http://de.wikipedia.org/wiki/HSV-Farbraum

Definition at line 147 of file frameconversions.c.


Generated on Sun Sep 28 21:20:01 2008 for Guard by  doxygen 1.5.6