Image fuzzy recognition C + + code based on OPECV 3.1

Source: Internet
Author: User
Tags mul

opencv3.1 +windows10+ vs2015 Configuration See article

WIN10 vs2015 Configuration Opencv3.1.0 process detailed (GO)

Code tested, highly recognized, test image 50w, recognition rate of more than 90%

If you can combine the Microsoft Oxford Program API to identify picture items HTTPS://WWW.AZURE.CN/PROJECTOXFORD/DEMO/VISION#OCR

#include <stdio.h>#include<stdlib.h>#include<ctype.h>#include<iostream>#include"highgui.h"#include"cvaux.h"Iplimage*Praw;floatVideoblurdetect (iplimage*data) {    intWidth=data->Widthstep; intHeight=data->height; ushort* Sobeltable =New ushort[width*height]; memset (sobeltable,0, width*height*sizeof(ushort)); intI, J, Mul; Uchar* Udata = (uchar*) data->ImageData;  for(i =1, mul = I*width; I < height-1; i++, Mul + =width) for(j =1; J < Width-1; J + +) Sobeltable[mul+j]=abs (udata[mul+j-width-1] +2*udata[mul+j-1] + udata[mul+j-1+width]-Udata[mul+j+1-width]-2*udata[mul+j+1]-udata[mul+j+width+1]);  for(i =1, mul = I*width; I < height-1; i++, Mul + =width) for(j =1; J < Width-1; J + +)            if(Sobeltable[mul+j] < -|| SOBELTABLE[MUL+J] <= sobeltable[mul+j-1] ||Sobeltable[mul+J] <= sobeltable[mul+j+1]) Sobeltable[mul+j] =0; intTotlen =0; intTotcount =1; Uchar Suddenthre= -; Uchar Samethre=3;  for(i =1, mul = I*width; I < height-1; i++, Mul + =width) {         for(j =1; J < Width-1; J + +)        {            if(sobeltable[mul+J]) {intCount =0; Uchar Tmpthre=5; Uchar Max= Udata[mul+j] > udata[mul+j-1] ?0:1;  for(intt = j; T >0; t--) {Count++; if(ABS (UDATA[MUL+T)-udata[mul+t-1]) >Suddenthre) Break; if(Max && udata[mul+t] > udata[mul+t-1])                         Break; if(!max && udata[mul+t] < udata[mul+t-1])                         Break; intTMP =0;  for(ints = t; s >0; s--)                    {                         if(ABS (Udata[mul+t]-udata[mul+s]) <Samethre) {tmp++; if(tmp > Tmpthre) Break; }                        Else  Break; }                    if(tmp > Tmpthre) Break; } Max= Udata[mul+j] > udata[mul+j+1] ?0:1;  for(intt = j; T < width; t++) {Count++; if(ABS (UDATA[MUL+T)-udata[mul+t+1]) >Suddenthre) Break; if(Max && udata[mul+t] > udata[mul+t+1])                         Break; if(!max && udata[mul+t] < udata[mul+t+1])                         Break; intTMP =0;  for(ints = t; s < width; s++)                    {                        if(ABS (Udata[mul+t]-udata[mul+s]) <Samethre) {tmp++; if(tmp > Tmpthre) Break; }                        Else  Break; }                    if(tmp > Tmpthre) Break; } Count--; Totcount++; Totlen+=count; }        }    }    floatresult = (float) totlen/Totcount; Delete[] sobeltable; returnresult;}intMain () {//cvcapture* cvcreatecameracapture ( -1);            floatre; Iplimage* Praw=cvloadimage ("D:/123.jpg", Cv_load_image_grayscale); Re=Videoblurdetect (Praw); Std::cout<<re; Cvnamedwindow ("Example", cv_window_autosize); Cvshowimage ("Example", Praw); Cvwaitkey (0); Cvreleaseimage (&Praw); Cvdestroywindow ("Example"); return 0;}

Image fuzzy recognition C + + code based on OPECV 3.1

Related Article

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.