Difference between revisions of "CUVI by Example"
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==Motion Detection== | |||
<p>CUVI library comes with all the image processing essentials that can be used to build countless applications. For example the '''Computer Vision''' module of CUVI can be used for motion and intrusion detection in a live video stream and tracking an object of interest throughout series of cameras installed in a premises. The processing pipeline for motion detection goes as follows:</p> | <p>CUVI library comes with all the image processing essentials that can be used to build countless applications. For example the '''Computer Vision''' module of CUVI can be used for motion and intrusion detection in a live video stream and tracking an object of interest throughout series of cameras installed in a premises. The processing pipeline for motion detection goes as follows:</p> | ||
*Read a frame from the camera stream | *Read a frame from the camera stream | ||
Line 56: | Line 57: | ||
f->sigma = 0.7f; | f->sigma = 0.7f; | ||
cuviCreateFilterSpecial(f,CUVI_FILTER_GAUSSIAN); | cuviCreateFilterSpecial(f,CUVI_FILTER_GAUSSIAN); | ||
//Image size | |||
CuviSize size = cuviSize(width,height); | |||
//Buffer Images on GPU | //Buffer Images on GPU | ||
CuviImage* gFrame = new CuviImage( | CuviImage* gFrame = new CuviImage(size,8,3); | ||
CuviImage* gimg1 = new CuviImage( | CuviImage* gimg1 = new CuviImage(size,8,1); | ||
CuviImage* gimg2 = new CuviImage( | CuviImage* gimg2 = new CuviImage(size,8,1); | ||
//Region of Interest in the video frame | //Region of Interest in the video frame | ||
Line 71: | Line 75: | ||
do | do | ||
{ | { | ||
//Read a Video Frame and populate GPU image with it | //Read a Video Frame on host 'frame' and populate GPU image with it | ||
gFrame->upload(frame->imageData); | gFrame->upload(frame->imageData,frame->widthStep); | ||
//Converting to Gray Image for computations | //Converting to Gray Image for computations | ||
Line 139: | Line 143: | ||
{{#ev:vimeo|38484537|500}} | {{#ev:vimeo|38484537|500}} | ||
<p>Here's an exact same example applied on a video feed of a webcam</p> | <p>Here's an exact same example applied on a video feed of a webcam</p> | ||
==Demosaic Example== | |||
CUVI demosaic, especially DFPD version is one of the most used and sought after feature of library. The sheer speed of debayering with CUVI linear debayer approach and the perfection in the resultant image in DFPD approach makes it the most demanded function of the library by camera manufacturers and video houses alike. In this example, we'll demonstrate how easy to use CUVI's own demosacing with just few lines of code. | |||
{| | |||
|style="font-size:130%;"| | |||
<syntaxhighlight lang="cpp"> | |||
#include <cuvi.h> | |||
CuviBayerSeq sensorAlignment = CuviBayerSeq::CUVI_BAYER_RGGB; | |||
// 8 bits data in an 8 bit container. Setting this is very important | |||
Cuvi32s containerBits = 8; | |||
Cuvi32s dataBits = 8; | |||
//Load and Upload image to GPU | |||
CuviImage input("D:/lighthouse_8bit_RGGB.tif", CUVI_LOAD_IMAGE_GRAYSCALE_KEEP_DEPTH); | |||
input.setDataBits(dataBits); | |||
//Create container for 3-channel output image | |||
CuviImage output(input.size(), containerBits, 3); | |||
//Perform Demosaic DFPD | |||
cuvi::colorOperations::DFPD(input, output, sensorAlignment); | |||
//Save resultant image to file | |||
cuvi::io::saveImage(output, "D:/lighthouse.tif"); | |||
</syntaxhighlight> | |||
|} | |||
[[File:Lighthouse.jpg|700px]] |
Revision as of 16:44, 27 March 2018
Motion Detection
CUVI library comes with all the image processing essentials that can be used to build countless applications. For example the Computer Vision module of CUVI can be used for motion and intrusion detection in a live video stream and tracking an object of interest throughout series of cameras installed in a premises. The processing pipeline for motion detection goes as follows:
- Read a frame from the camera stream
- Select Strong Features in that Frame using CUVI
- Read next frame
- Track features of first frame in the second frame using CUVI
- Set alarm if motion is detected
The CUVI functions used in this example are goodFeaturesToTrack() and trackFeatures(). For simplicity we have removed the I/O part on host side from the code
|
Here's an exact same example applied on a video feed of a webcam
Demosaic Example
CUVI demosaic, especially DFPD version is one of the most used and sought after feature of library. The sheer speed of debayering with CUVI linear debayer approach and the perfection in the resultant image in DFPD approach makes it the most demanded function of the library by camera manufacturers and video houses alike. In this example, we'll demonstrate how easy to use CUVI's own demosacing with just few lines of code.
|