OpenCV using the Harris algorithm for angular point detection

Source: Internet
Author: User

Pure reading, please visit OPENCV using the Harris Algorithm for corner detection

Source

Kqwopencvfeaturesdemo

A corner point is an intersection of two edges or a point that has several significant edge orientations in a local neighborhood. Harris Corner Point Detection is one of the most common techniques in corner detection.

The Harris corner detector uses a sliding window on the image to calculate the brightness change.

Packaging

The Rxjava is used here. This is mainly because picture processing is a time-consuming operation that blocks threads and, in order to prevent the interface from stalling, uses Rxjava for thread switching.

/** * Harris Corner Detection * * @param bitmap image to be detected */ Public void Harris(Bitmap Bitmap) {if(NULL! = Msubscriber) Observable. Just (bitmap)//Detection Edge. Map (NewFunc1<bitmap, mat> () {@Override                     PublicMatPager(Bitmap Bitmap) {Mat Graymat =NewMat (); Mat cannyedges =NewMat ();//Bitmap switch to MatMat src =NewMat (Bitmap.getheight (), Bitmap.getwidth (), CVTYPE.CV_8UC4); Utils.bitmaptomat (bitmap, SRC);//Original GrayImgproc.cvtcolor (SRC, Graymat, imgproc.color_bgr2gray);///Canny edge detector detects image edgesImgproc.canny (Graymat, Cannyedges,Ten, -);returnCannyedges; }                })//Harris Diagonal Detection. Map (NewFunc1<mat, bitmap> () {@Override                     PublicBitmapPager(Mat cannyedges) {Mat Corners =NewMat (); Mat TEMPDST =NewMat ();//Find corner pointsImgproc.cornerharris (Cannyedges, TEMPDST,2,3,0.04);//Normalization of the output of the Harris corner pointMat Tempdstnorm =NewMat (); Core.normalize (TEMPDST, Tempdstnorm,0,255, Core.norm_minmax); Core.convertscaleabs (tempdstnorm, corners);//Draw corner points on new imagesRandom r =NewRandom (); for(inti =0; I < Tempdstnorm.cols (); i++) { for(intj =0; J < Tempdstnorm.rows (); J + +) {Double[] Value = Tempdstnorm.get (j, I);if(value[0] > Max) {Core.circle (corners,NewPoint (I, J),5,NewScalar (R.nextint (255),2)); }                            }                        }//Mat turn bitmapBitmap processedimage = Bitmap.createbitmap (Corners.cols (), Corners.rows (), Bitmap.Config.ARGB_8888); Utils.mattobitmap (corners, processedimage);returnProcessedimage;                 }}). Subscribeon (Schedulers.io ()). Observeon (Androidschedulers.mainthread ()) . Subscribe (msubscriber);}
Use
//Image feature extraction tool classMfeaturesutil =NewFeaturesutil (NewSubscriber<bitmap> () {@Override     Public void oncompleted() {//Picture processing completeDismissprogressdialog (); }@Override     Public void OnError(Throwable e) {//Picture handling exceptionDismissprogressdialog (); }@Override     Public void OnNext(Bitmap Bitmap) {//Get to the processed pictureMimageview.setimagebitmap (bitmap); }});//Harris Corner Point detectionMfeaturesutil.harris (Mselectimage);

OpenCV using the Harris algorithm for corner detection

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.