-
Notifications
You must be signed in to change notification settings - Fork 2
LeanCV
The LeanCV library is a set of vision algorithms with a simple and consistent API. It contains functions for Debayering, Image conversions and Filters and more...
LeanCV uses the same primitives as OpenCV. That makes it easy to use OpenCV and LeanCV in one project.
Contributed by Beat Küng
- Oscar v2.1 or greater (only the headers are used)
See Oscar Code Collection for general information how to use an OSC-CC module.
Use #include <leancv.h>
to include LeanCV into an application.
Important: Include leancv.h
before stl headers (e.g. iostream).
All Functions use the image datatype IplImage
, which is from OpenCV. They all begin with the prefix lcv
.
-
depth:
IPL_DEPTH_8U
orIPL_DEPTH_16FRACT
. -
width: Must be a multiple of
LCV_WIDTH_ALIGN
= 4. - channels: Either 1 (gray) or 3 (BGR color format).
See Supported Image Formats for more information about valid arguments.
Allocate image header and image data.
Arguments:
- struct CvSize size: image size.
- int depth: image depth
- int channels: Image Channel count.
- IplImage*: Created Image.
IplImage* img=lcvCreateImage(cvSize(OSC_CAM_MAX_IMAGE_WIDTH, OSC_CAM_MAX_IMAGE_HEIGHT), IPL_DEPTH_8U, 1);
Allocate Image Header only. Set img->imageData
pointer to the image data after calling the function.
Note that the imageData
pointer must be aligned. See lcvAlignImage
.
Arguments:
- struct CvSize size: image size.
- int depth: image depth
- int channels: Image Channel count.
- IplImage*: Created Header.
IplImage* img=lcvCreateImageHeader(cvSize(OSC_CAM_MAX_IMAGE_WIDTH, OSC_CAM_MAX_IMAGE_HEIGHT), IPL_DEPTH_8U, 1); img->imageData=(char*)pic;
Align an image pointer to the next multiple of LCV_IMG_ALIGN
. Effective image size must be LCV_IMG_ALIGN
larger than needed.
Arguments:
- char* img: pointer to be aligned
- char*: aligned pointer.
uint8 pic[OSC_CAM_MAX_IMAGE_HEIGHT*OSC_CAM_MAX_IMAGE_WIDTH + LCV_IMG_ALIGN]; IplImage* img=lcvCreateImageHeader(cvSize(OSC_CAM_MAX_IMAGE_WIDTH, OSC_CAM_MAX_IMAGE_HEIGHT), IPL_DEPTH_8U, 1); img->imageData=lcvAlignImage((char*)pic);
Deallocate image header and data.
Arguments:
- IplImage** image: Address of the image pointer.
- void
[...] lcvReleaseImage(&img);
Deallocate image header only.
Arguments:
- IplImage** image: Address of the image pointer.
- void
Convert a raw image, captured with a color sensor to another format.
Debayer a captured image to BGR color format. Input channel count is 1 and the output image must have 3 channels. Input and output image must have the same size. Arguments:
- IplImage* raw_img: the captured image. Must have 1 channel.
- enum EnBayerOrder order: Bayer order.
- IplImage* output: the debayered output image. Must have 3 channels.
- void
Debayer a captured image to half size with color format gray. Both images must have 1 channels and the output image must have half the width and height from the raw image. Arguments:
- IplImage* raw_img: the captured image. Must have 1 channel.
- enum EnBayerOrder order: Bayer order.
- IplImage* output: the debayered output image. Must have 1 channels.
- void
Write an image to a BMP image file. Arguments:
- IplImage* img: pointer to an image
- char* file_name: file name string.
- OSC_ERR: 0 on success. Appropriate error code otherwise.
get a pointer to a BMP image header.
Note: Release created image with lcvReleaseImage
after usage!
Arguments:
- IplImage* img: pointer to an image
- char** header_out: this pointer will be set to the header.
- int: header size on success. < 0 on error.
Read a BMP image file to an IplImage structure. Arguments:
- char* file_name: BMP image file name.
- IplImage*: Created Image on success, NULL on error.
Reverse image rows. Used by lcvBmpRead
, because BMP stores the image upside down.
Arguments:
- IplImage* img: pointer to the image.
- void
Convert one image type to another. Currently conversions between image depth IPL_DEPTH_16FRACT
and IPL_DEPTH_8U
is supported.
Arguments:
- IplImage* img_in: pointer to the input image.
- IplImage* img_out: pointer to the resulting image.
- void
Converts a grayscale image to a binary image. Input image can be the same as output image. Image depth can be either IPL_DEPTH_16FRACT or IPL_DEPTH_8U. The resulting image contains only 0 and 1. Arguments:
- IplImage* img_in: pointer to the input image.
- IplImage* img_out: pointer to the resulting image.
- int threshold: if input pixel is greater than threshold, the result will be 1 and 0 if pixel is smaller than the threshold value.
- void
This function labels the binary image by checking for connected components based on run-length encoding. This function outputs a representation of the binary image based on connected sets of runs. The sets of runs are refered to as 'objects' (=regions of foreground pixels). Arguments:
- IplImage* img_in: pointer to the input image. One channel, binary and depth must be
IPL_DEPTH_8U
- LCV_REGIONS regions: pointer to a regions data struction. result will be stored here
- void
Extract Properties of the Regions (=labeled binary Image), calculated with the function lcvLabelBinary
.
Arguments:
- LCV_REGIONS regions: pointer to a regions data struction
- void
This function draws the centroids of the Regions as small crosses. Arguments:
- IplImage* img_in: pointer to the input image.
- LCV_REGIONS regions: pointer to a regions data struction.
- const char* color: the drawing color. size must be img_in->nChannels * image depth/8
- void
This function draws the bounding boxes of the Regions as rectangles. Arguments:
- IplImage* img_in: pointer to the input image.
- LCV_REGIONS regions: pointer to a regions data struction.
- const char* color: the drawing color. size must be img_in->nChannels * image depth/8
- void