Interesting phenomenon of camera image comparison

Source: Internet
Author: User

Recently in the study OpenCV, did a camera before and after the frame comparison effect, found by comparison, can find the object contour.


The specific algorithm is shown below:


Compare two pictures bool Copencvcameractrl::D ifftwopic () {Mat Pre_gray;cv::namedwindow ("Showcamera"); Cv::namedwindow (_T ("JG") ); while (true) {//Get image mat Frame, BIGFRAME;VC >> bigframe;if (!bigframe.data) {continue;} frame = Bigframe (Cv::rect (+/-), frame = Bigframe;cv::imshow ("Showcamera", frame); Mat Frame_gray;cv::cvtcolor (frame, frame_gray, Cv_bgr2gray); if (!pre_gray.empty ()) {//Compare image Mat Abcdiff, EROSION_DST;CV :: Absdiff (Pre_gray, Frame_gray, Abcdiff);//corrosion operation/*int erosion_size = 1;int Erosion_type = morph_rect; Mat element = Getstructuringelement (erosion_type,size (2*erosion_size + 1, 2*erosion_size+1), point (Erosion_size, Erosi on_size))////Corrosion operation Erode (Abcdiff, erosion_dst, Element); *///Two value Operation Mat Matthre;threshold (Abcdiff, Matthre, 5, 255, 0); c V::imshow (_t ("JG"), Matthre), int ncount = Cv::countnonzero (Abcdiff), if (Ncount >) {//beep (5500,150);}} Save Image Frame_gray.copyto (Pre_gray); Cv::waitkey (30);} return TRUE;}


Process the effect as shown in:



The effect is the effect of non-corrosive treatment, if the addition of corrosion treatment, the entire picture will be black. Note that the difference points in the contour you see are discrete points that cannot be referenced directly.

Interesting phenomenon of camera image comparison

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.