[Opencv learning] Laplace transformation (Video boundary detection)

Source: Internet
Author: User

Author: gnuhpc
Source: http://www.cnblogs.com/gnuhpc/

# Include "CV. H "# include" highgui. H "# include <ctype. h> # include <stdio. h> int main (INT argc, char ** argv) {iplimage * Laplace = 0; iplimage * coloelaploud = 0; iplimage * PLANeS [3] = {0, 0 }; // multiple image faces cvcapture * capture = 0; If (argc = 1 | (argc = 2 & strlen (argv [1]) = 1 & isdigit (argv [1] [0]) {capture = cvcapturefromcam (-1);} else if (argc = 2) {capture = cvcapturefromavi (argv [1]);} If (! Capture) {fprintf (stderr, "cocould not initialize capturing... /n "); Return-1;} cvnamedwindow (" Main ", 0); For (;) {iplimage * frame = 0; int I; frame = cvqueryframe (capture); // capture from the camera or file and return a frame if (! Frame) {break;} If (! Laplace) {for (I = 0; I <3; I ++) {planes [I] = cvcreateimage (cvsize (frame-> width, frame-> height ), 8, 1);} Laplace = cvcreateimage (cvsize (frame-> width, frame-> height), ipl_depth_16s, 1); coloelaplace = cvcreateimage (cvsize (frame-> width, frame-> height), 8, 3);} cvcvtpixtoplane (frame, planes [0], planes [1], planes [2], 0 ); // # define cvcvtpixtoplane cvsplit for (I = 0; I <3; I ++) {cvlaplace (planes [I], Laplace, 3 ); // calculate the Laplacian transformation of image planes [I] cvconvertscaleabs (Laplace, planes [I],); // planes [] = ABS (Laplace )} cvcvtplanetopix (planes [0], planes [1], planes [2], 0, coloelaplace); // # define cvcvtplanetopix cvmerge coloelap--> origin = frame-> origin; cvshowimage ("Main", coloelaploud); If (cvwaitkey (10) >=0) {break ;}} cvreleasecapture (& capture); cvdestroywindow ("Main "); return 0 ;}

 

Author: gnuhpc

Source: http://www.cnblogs.com/gnuhpc/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.