vendredi 21 avril 2017

RedCV

As seen in previous posts, Red language is smart for basic image processing. However, since Red is still young and under development, most of useful functions are not yet implemented. This is why RedCV exists.

What is RedCV


RedCV means Red Language Open Source Computer Vision Library. It is a collection of Red functions and routines that give access to many popular image processing algorithms. RedCV provides cross-platform high level API that includes actually about 150 functions. RedCV has no dependencies on external libraries.
 

Where to get RedCV

Go https://github.com/ldci/redCV and download library.

Using RedCV library

RedCV library intensively uses Red/System DSL developed by Nénad to propose low-level system programming capabilitiesMost of operators are calling Red/System routines for faster image rendering. All redCV routines can be directly called from a red program. For an easier access, Red/System routines are exported as red functions you can call in your code. RedCV functions are documented. You'll find in RedCV_Manual.pdf all informations you need for functions. 

Attention: Since your red code is calling routines, code must be compiled.

All includes to redCV libraries are declared in a single file (located in /libs/redcv.red). You just need to include redcv.red file in your Red programs.

#include %../../libs/redcv.red ; for red functions

RedCV basic structures

RedCV library intensively uses 2 basic structures for image processing.

Image

RedCV directly uses Red image! datatype. Loaded or processed images by RedCV are in ARGB format (a tuple). Images are 8-bit and internally uses bytes [0..255] to make a binary string. Images are 4-channels and actually Red can't create 1, 2 or 3-channels images. Similarly Red can't create 16-bit (0..65536) 32-bit or 64-bit (0.0..1.0) images.

Pixel value for each channel can be easily accessed by a pointer
pixel >>> 24                           : Alpha (transparency) channel
pixel and FF0000h >> 16       : Red channel
pixel and FF00h >> 8             : Green channel
pixel and FFh                         : Blue channel

Matrix

Matrix! Datatype is not yet implemented by Red. We simulate matrices with Red vector! datatype. Work under progress. Matrices are 2-D with n lines *m columns. Matrix element can be Char!, Integer! or Float! Matrices are used for faster image processing.

A first simple example: Random matrix

Red [
    Title: "Matrix tests"
    Author: "Francois Jouen"
    File:    %RandomMatrix.red
    Needs:   'View
]
#include %../../libs/redcv.red ; for redCV functions
img: rcvCreateImage 512x512         ; a 512x512 image
mat: rcvCreateMat 'char! 8 512x512  ; a 512X512 matrix of chars
title: "1-Channel Matrix -> Red Image"
rcvRandomMat mat 255                ; 8-bits and 1-channel random matrix
rcvMat82Image mat img               ; converts matrix to Red Image
dest: rcvNamedWindow title          ; creates a window
rcvResizeWindow dest 512x512        ; resizes the window
rcvShowImage dest img               ; shows image
do-events


Aucun commentaire:

Enregistrer un commentaire