Commit 72f1cd86 authored by Vasily Khoruzhick's avatar Vasily Khoruzhick

lib: Document assembling functions

Signed-off-by: Vasily Khoruzhick's avatarVasily Khoruzhick <anarsoul@gmail.com>
parent dabcae7b
Pipeline #10922 failed with stages
......@@ -163,6 +163,18 @@ static unsigned int do_movement_estimation(struct fpi_frame_asmbl_ctx *ctx,
return total_error / num_stripes;
}
/**
* fpi_do_movement_estimation:
* @ctx: #fpi_frame_asmbl_ctx - frame assembling context
* @stripes: linked list of #fpi_frame
* @stripes_len: size of the list
*
* #fpi_do_movement_estimation does movement estimation between adjacent
* frames, it popules delta_x and delta_y values of each #fpi_frame.
* This function is used for devices that don't do movement estimation
* in hardware. If hardware movement estimation is supported driver
* should populate delta_x and delta_y instead.
*/
void fpi_do_movement_estimation(struct fpi_frame_asmbl_ctx *ctx,
GSList *stripes, size_t num_stripes)
{
......@@ -236,6 +248,17 @@ static inline void aes_blit_stripe(struct fpi_frame_asmbl_ctx *ctx,
}
}
/**
* fpi_assemble_frames:
* @ctx: #fpi_frame_asmbl_ctx - frame assembling context
* @stripes: linked list of #fpi_frame
* @stripes_len: size of the list
*
* #fpi_assemble_frames assembles individual frames into a single image.
* It expects delta_x and delta_y of #fpi_frame to be populated.
*
* Returns: a newly allocated #fp_img.
*/
struct fp_img *fpi_assemble_frames(struct fpi_frame_asmbl_ctx *ctx,
GSList *stripes, size_t stripes_len)
{
......@@ -361,7 +384,17 @@ static void interpolate_lines(struct fpi_line_asmbl_ctx *ctx,
}
}
/* Rescale image to account for variable swiping speed */
/**
* fpi_assemble_lines:
* @ctx: #fpi_frame_asmbl_ctx - frame assembling context
* @lines: linked list of lines
* @lines_len: size of the list
*
* #fpi_assemble_lines assembles individual lines into a single image.
* It also rescales image to account variable swiping speed.
*
* Returns: a newly allocated #fp_img.
*/
struct fp_img *fpi_assemble_lines(struct fpi_line_asmbl_ctx *ctx,
GSList *lines, size_t lines_len)
{
......
......@@ -22,12 +22,34 @@
#include <fprint.h>
/**
* fpi_frame:
* @delta_x: X offset of the frame
* @delta_y: Y offset of the frame
* @data: bitmap
*
* #fpi_frame is used to store frames for swipe sensors. Driver should
* populate delta_x and delta_y if device supports hardware movement
* estimation
*/
struct fpi_frame {
int delta_x;
int delta_y;
unsigned char data[0];
};
/**
* fpi_frame_asmbl_ctx
* @frame_width: width of frame
* @frame_height: height of frame
* @image_width: resulting image width
* @get_pixel: pixel accessor, returns pixel brightness at x,y of frame
*
* #fpi_frame_asmbl_ctx is context for frame assembling routines.
* Driver should define its own #fpi_frame_asmbl_ctx depending on
* hardware parameters of scanner. image_width is usually 25% wider than
* frame_width to take into account horizontal movement
*/
struct fpi_frame_asmbl_ctx {
unsigned int frame_width;
unsigned int frame_height;
......@@ -44,6 +66,27 @@ void fpi_do_movement_estimation(struct fpi_frame_asmbl_ctx *ctx,
struct fp_img *fpi_assemble_frames(struct fpi_frame_asmbl_ctx *ctx,
GSList *stripes, size_t stripes_len);
/**
* fpi_line_asmbl_ctx
* @line_width: width of line
* @max_height: maximal height of assembled image
* @resolution: scale factor used for line assembling routines.
* @median_filter_size: size of median filter for movement estimation
* @max_search_offset: indicates how many lines forward should assemlbing
* routines look while searching for next line.
* Value depends on how fast hardware sends frames.
* @get_deviation: function that returns numerical difference between two
* lines. Higher values means lines are more different.
* If scanner returns two lines at a time, this function
* should estimate difference between second lines.
* @get_pixel: pixel accessor, returns pixel brightness at x of line
*
* #fpi_line_asmbl_ctx is context for line assembling routines.
* Driver should define its own #fpi_line_asmbl_ctx depending on
* hardware parameters of scanner. Swipe scanners of this type usually
* return two lines, second line is often narrower than first and is used
* for movement estimation.
*/
struct fpi_line_asmbl_ctx {
unsigned int line_width;
unsigned int max_height;
......
......@@ -615,7 +615,18 @@ API_EXPORTED int fp_minutia_get_coords(struct fp_minutia *minutia, int *coord_x,
return 0;
}
/* Calculate squared standand deviation */
/**
* fpi_std_sq_dev:
* @buf: buffer (usually bitmap, one byte per pixel)
* @size: buffer size
*
* Calculates squared standard deviation of the buffer. I.e.:
* mean = sum(buf[0..size]) / size;
* sq_dev = sum( (buf[0.size] - mean) ^ 2).
* It's usually used to determine whether image is empty.
*
* Returns: Squared standard deviation.
*/
int fpi_std_sq_dev(const unsigned char *buf, int size)
{
int res = 0, mean = 0, i;
......@@ -638,7 +649,19 @@ int fpi_std_sq_dev(const unsigned char *buf, int size)
return res / size;
}
/* Calculate normalized mean square difference of two lines */
/* Calculate normalized mean squared difference of two l */
/**
* fpi_mean_sq_diff_norm:
* @buf1: buffer (usually bitmap, one byte per pixel)
* @buf2: buffer (usually bitmap, one byte per pixel)
* @size: buffer size of smallest buffer
*
* Calculates normalized mean square difference of two lines. I.e.:
* sq_diff = sum( (buf1[0..size] - buf2[0..size]) ^ 2 ) / size
* It's usually used to get numerical difference between two images
*
* Returns: normalized mean squared difference.
*/
int fpi_mean_sq_diff_norm(unsigned char *buf1, unsigned char *buf2, int size)
{
int res = 0, i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment