[Opencv] video reading and some simple image processing

Source: Internet
Author: User
1. Preface

As a computer image processing tool, opencv began to show some irreplaceable advantages due to free disclosure, copyright, and so on (it has been shown for a long time ). Well, I have been working with MATLAB in my graduate school. I always feel like debugging, verification, or Matlab is useful! Not long ago, I started to get in touch with opencv. I always felt that although it was a tool, the water was very deep. Well, it's always a pitfall about opencv. Record your learning trajectory.
Self-built slot 1: There are some pitfalls in the basic image processing, and some of them are not completed. After a few days, start to fill in the pitfalls, not too bad (= !! Self-hypnosis)
Self-built tucao 2: but no one is really waiting to see it (= Good sang Xin !)

2. Video reading and Image Display 2.1 read images from AVI Files

For image processing, the initial experiment code basically starts by reading an image and displaying it. This is the "Hello world!" of image processing !". Opencv reads an image and displays the following code.

<code class="hljs cs has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent;">IplImage* ori= cvLoadImage(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"..\\Data\\Fig0320(4) (bottom_left).tif"</span>,Gray_image);    cvNamedWindow(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"Original"</span>, CV_WINDOW_AUTOSIZE );   <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//new window</span>cvShowImage(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"Original"</span>,ori);        <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//show</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

In fact, it is equivalent toimread(),imshow()Andfigure()It is worth noting that if you want to expand the image in the window along with the window, you can use the cv_window_normal style, that is, the following code.

<code class="hljs scss has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-function" style="box-sizing: border-box;">cvNamedWindow(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"Original"</span>, CV_WINDOW_NORMAL )</span>;   <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//new window</span><span class="hljs-function" style="box-sizing: border-box;">cvShowImage(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"Original"</span>,ori)</span>;        <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//show</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

The video reading function is similar to the image reading function.

cvCreateFileCapture(argv[1])Read a video. Then use the FunctioncvQueryFrame(capture)Take one frame of the image, and then display the image (cvShowImage()). It is displayed frame by frame at a certain interval.



Http://www.v1bo.com/110695260
Http://www.v1bo.com/110695359
Http://www.v1bo.com/110695176
Http://www.v1bo.com/110695096
Http://www.v1bo.com/110695179
Http://www.v1bo.com/110695366
Http://www.v1bo.com/110694876
Http://www.v1bo.com/110695367
Http://www.v1bo.com/110694877
Http://www.v1bo.com/110694991
Http://www.v1bo.com/110695186
Http://www.v1bo.com/110694883
Http://www.v1bo.com/110694884
Http://www.v1bo.com/110694992
Http://www.v1bo.com/110695376
Http://www.v1bo.com/110694994
Http://www.v1bo.com/110695377
Http://www.v1bo.com/110695378
Http://www.v1bo.com/110694998
Http://www.v1bo.com/110694999
Http://www.v1bo.com/110695380
Http://www.v1bo.com/110695194
Http://www.v1bo.com/110695290
Http://www.v1bo.com/110695291
Http://www.v1bo.com/110695199
Http://www.v1bo.com/110695802
Http://www.v1bo.com/110695385
Http://www.v1bo.com/110695807
Http://www.v1bo.com/110695408
Http://www.v1bo.com/110695409
Http://www.v1bo.com/110695295
Http://www.v1bo.com/110695810
Http://www.v1bo.com/110695811
Http://www.v1bo.com/110695702
Http://www.v1bo.com/110695393
Http://www.v1bo.com/110695814
Http://www.v1bo.com/110695705
Http://www.v1bo.com/110695396
Http://www.v1bo.com/110695603
Http://www.v1bo.com/110695415
Http://www.v1bo.com/110695816
Http://www.v1bo.com/110695902


[Opencv] video reading and some simple image processing

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.