Warning: mysqli_query(): MySQL server has gone away in /home/wwwroot/syntaxbug.com/wp-includes/wp-db.php on line 1924

Warning: mysqli_query(): Error reading result set's header in /home/wwwroot/syntaxbug.com/wp-includes/wp-db.php on line 1924
detection – Page 3 – SyntaxBug

Target detection (2) Feature extraction of traditional target detection and recognition – Viola Jones detection principle based on Haar-like features

TableofContents Introduction integralplot Trainoptimalweakclassifier Trainastrongclassifier strongclassifier Cascadeclassifier Introduction TheViolaJonesdetectorconsistsofthreecoresteps,namelyHaar-likefeatureandintegralmap,Adaboostclassifierandcascadeclassifier.Supposethatduringtargetdetection,suchasub-windowisneededtocontinuouslyslideandmoveintheimagetobedetected.Everytimethesub-windowreachesaposition,thecharacteristicsoftheareawillbecalculated,andthenthetrainedcascadeclassifierwillbeusedtoFeaturesarefiltered,andaslongasthefeaturepassesthescreeningofallstrongclassifiers,theareaisdeterminedtobethetargetarea. AsshowninFigure9.3,thereare5differentHaar-likefeatureoperators.Assumethatthetotalgrayvalueoftheblackareaineachpictureis?,andthetotalgrayvalueofthewhiteareais.Theresultobtainedis:Haar-likeeigenvaluesofthesub-windowarea. Figure9.3haarfeatures Therectangularfeaturecanbelocatedatanypositionintheimagewindow,anditssizecanalsobechangedatwill.Therefore,therectangularfeaturevalueisdeterminedbythethreefactorsofhaarfeatureoperatorcategory,rectangularpositionandrectangularsize.Therefore,changesincategory,size,andposition,sothatsmallerpictureswillalsocontainmanyrectangularfeatures. Takinga24×24windowasanexample,fivedifferentHaar-likefeatureoperatorsareusedforcalculationinFigure9.3.ThenumberofeigenvaluesofthefiveHaar-likefeatureoperatorsare:43200,43200,27600,27600,20736,atotalof160381.Theimagewindowof24×24sizealonehasmorethan160,000featurevalues.Now,wearefacedwithtwoproblems: Facedwithsomanyeigenvalues,howtooptimizecalculationsandreducetheamountofcalculations? Therearetoomanyeigenvalues.Theremustbesomeeigenvaluesthatarebetteratidentifyingpositivesamplesandnegativesamples,andsomethatarenotgoodatdistinguishingpositivesamplesfromnegativesamples.Sample.Sohowtofindthesegood,excellentfeatures,thatis,theoptimalweakclassifier. IntegralChart First,tosolvethefirstproblem,youneedtousetheintegralmap.Foragrayscaleimage,thevalueofanypointintheintegralmapisthegrayscaleofallpointsintherectangularareaformedbythispointfromtheupperleftcorneroftheoriginalimage.Thesumofthevalues,asshowninFigure9.4:theleftpictureistheoriginalimage,therightpictureistheintegralimage,the3rdrowand4thcolumnintheintegralimagearethepixelsumoftheyellowboxareaintheoriginalimage,the5thintheintegralimageThesecondcolumnoftherowisthepixelsumofthepurpleboxareaintheoriginalimage. Figure9.4Integralplot TheformulashowninFigure9.4canconstructanintegralgraph,butgenerallythefollowingformulaisusedtoconstructanintegralgraph: representsthecumulativesumofthepixelvaluesofthefirstjrowoftheimagei,initialized Userepresentsanintegralimage,initialized Scantheimagelinebylineandcalculatetheaccumulationofeachpixelii,jand,thecalculationmethodsareasfollows: Scantheimageonce.Whenthepixelinthelowerrightcorneroftheimageisreached,theintegralmapii(i,j)iscompleted.Howtocalculatethesumofpixelsinacertainrectangularareaoftheimagethroughtheintegralmap? AsshowninFigure9.5:Intheoriginalimage,therearefourareasA,B,C,andD,wherea,b,c,anddrepresentthefourverticesoftheDarea.HowtocalculatetheintegraldiagramofareaD? Figure9.5Imagearea Use,,,representa,binFigure9.5,respectively.Theintegralvaluesofthefourpointscandd.Usethefollowingequation9.3tocalculatethetotalgrayvalueofthepixelsinareaD: Accordingtotheabovetheory,itcanbefoundthataftertheintroductionofintegralmaptechnology,theHaar-likerectangularfeaturevalueofanimageisonlyaffectedbythevalueofitscorrespondingintegralmap,andthechangeofthecoordinatesoftheimage’spositionhasnocorrelationwithitsvalue.Inthisway,thetimetakentocalculatefeaturevaluescanbeshortenedwhencalculatingrectangularfeatures. Traintheoptimalweakclassifier Nowlet’ssolvethesecondproblem.Therearetoomanyfeatures,soweneedtoscreenthefeaturesandselecttheoptimalweakclassifier.TheinitialweakclassifiermaybejustabasicHaar-likefeature.ItcalculatestheHaar-likefeaturevalueoftheinputimageandcomparesitwiththefeaturevalueoftheinitialweakclassifiertodeterminewhethertheinputimageisaface.However,thisweakclassifierItistoocrudeandmaynotbebetterthanrandomjudgment.Theincubationofweakclassifiersistotrainweakclassifierstobetheoptimalclassifier.Notethattheoptimalclassifierisnotastrongclassifier,butaweakclassifierwitharelativelylowerror.,trainingaweakclassifierisactuallytheprocessofsettinguptheclassifier.Asforhowtosetuptheclassifierandwhattoset,let’sfirstlookatthemathematicalstructureoftheweakclassifierasshowninEquation9.4: Theparameterxisthecharacteristicwindow,prepresentsthedifferentdirectionsoftheinequality,withvaluesof1and-1,andgistherectangularwindow.ThecorrespondingHaar-likefeaturevalue,θ,isthejudgmentthresholdoftheweakclassifier. ThemostbasicweakclassifieronlycontainsoneHaar-likefeature,whichmeansthatthedecisiontreehasonlyonelayer,calledastump.Tocomparethefeaturevaluesoftheinputimageandtheweakclassifierfeatures,athresholdisneeded.Whenthefeaturevalueoftheinputimageisgreaterthanthethreshold,itisdeterminedtobeaface.Theprocessoftrainingtheoptimalweakclassifierisactuallytofindasuitableclassifierthresholdsothattheclassifierhasthelowestjudgmenterrorforallsamples.Thespecificoperationprocessisasfollows: Findtheoptimalthresholdthatminimizestheclassificationerror.Withthisthreshold,thefirstoptimalweakclassifierisborn,ThebirthofthefirstoptimalweakclassifiermeansthatthebestHaar-likefeaturevaluehasbeenscreenedout. Trainstrongclassifier Weakclassificationisonlyaclassifierwithacertainclassificationability,anditsratiocannotmeetthebasicrequirementsforaclassifier,soitneedstobefurtherstrengthenedtobuildastrongclassifierbasedontheweakclassifier.Thespecifictrainingstepsareasfollows: Initializethesampletrainingset Trainingsampleset(x1,y1),…,(xn,yn),whereyi∈0,1,yiisthepositiveandnegativesampleidentifier,1ispositive,otherwiseitisnegative. Initializesampleweightsbasedonthenumberofpositiveandnegativesamples Theinitialweightofthepositivesampleis,theinitialweightofthenegativesampleis,wherem,listhetotalnumberoffacesamplesandthetotalnumberofnon-facesamples,andthetotalnumberofallsamplesisnem>,andsatisfytheconditionofn=m+l,isusedtorepresenttheweight,wheretreferstothetthalgorithmiteration,jreferstothejthoneinthetrainingsample Iterativetrainingofweakclassifiers StrongClassifier Thefinalstrongclassifierisrecordedas: Amongthem,indicatesthemaximumnumberoftrainingtimes. CascadeClassifier AstrongclassifiercanbeconstructedthroughthetrainingoftheaboveAdaBoostalgorithm,buttheaccuracyofsuchaclassifierstillneedstobeimproved,sothestrongclassifierisnotthefinalstructureoftheclassifier.Inordertomaketheaccuracyanddetectionefficiencyoftheclassifierbetter,youcanUsethecascademethodtocombinestrongclassifiersintoacascadeclassifier. Figure9.6Cascadeclassifier Infact,thepurposeoftrainingacascadeclassifieristomakedetectionmoreaccurate.ThedetectionsystemoftheHaarclassifiertakesanimageinrealityasinput,andthenperformsmulti-regionandmulti-scaledetectionontheimage.Theso-calledmulti-Regionistodividetheimageintomultipleblocksanddetecteachblock. Sincethephotosusedfortrainingareonlysmallimagesofabout20*20,multi-scaledetectionisrequiredforlargefaces.Multi-scaledetectionmechanismsgenerallyhavetwostrategies.Oneisnottochangethesizeofthesearchwindow.However,bycontinuouslyscalingtheimage,thismethodrequiresthecalculationofregionalfeaturevaluesforeachscaledimage,whichisnotefficient. Anothermethodistocontinuouslyinitializethesearchwindowsizetotheimagesizeduringtraining,continuouslyexpandthesearchwindow,andperformsearches,whichsolvesthedisadvantagesofthefirstmethod.Duringtheprocessofareaenlargement,thesamefacewillbedetectedmultipletimes,whichrequiresthemergingofareas.Nomatterwhichsearchmethodisused,alargenumberofsub-windowswillbeoutputfortheinputimage.Thesesub-windowswillbecontinuouslyfiltered,discardedorpassedbythefirstnodethroughthefilteringcascadeclassifier,asshowninFigure9.6. UsetheViolaJonesclassifierprovidedbyopencvtodetectfacesandeyes.Theimplementationcodeisasfollows: importcv2 #Loadclassifier eye_cascade=cv2.CascadeClassifier(cv2.data.haarcascades,’haarcascade_eye.xml’) img=cv2.imread(‘image/lenna.bmp’)#Loaddetectionimages gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) #Performtargetdetectiononimagesthroughtheclassifier […]

Vulnerability anti-connection detection combination: intranet penetration and multi-protocol reuse port

http://Yaklang.io anti-connection technology three axe Anti-connection service Multi-protocol port multiplexing Intranet penetration What is anti-connection? Why do it Many times, when we perform vulnerability detection, we cannot determine whether a vulnerability exists through the information returned by the application. But if the command/special operation is indeed executed, how do we prove that the command or […]

Weak password detection service implementation (multi-process, multi-thread, holy)

weak.py #!/usr/bin/env python # -*- coding: utf-8 -*- import global_par from global_par import * from weakcheck_tool import WEAK_CHECK import signal import os import errno import time import logging importsys import json import multiprocessing #pid import stomp from stomp import ConnectionListener import ConfigParser hand_count = 0 task_list = {} task_return_dic = {“type”:6, “status”:0, “task_id”:”0″, “tool”:”weak”, “data”:[ […]

Call the yolov5 model to implement the area detection function based on opencv

Call the yolov5 model to detect whether the specified type of object is within a fixed area based on opencv Introduction: File structure: The files in utils and models can be found in the official yolov5 files. These are required. This method is suitable for the pre-trained model of yolov5 and the pt model trained […]

Use opencv and dlib libraries (C++ code) to implement face liveness detection (blinking, mouth opening, shaking head detection)

Foreword This article uses opencv and dlib libraries, and uses C++ code to implement face detection, including blink detection, mouth opening detection, and shaking head detection, which can effectively distinguish static pictures from living objects. Effect display Dlib library introduction dlib is an open source C++ machine learning library that provides a series of algorithms […]

STM32 GPIO input – key detection

Main function code /** *************************************************** **************************** * @file main.c * @author fire * @version V1.0 * @date 2015-xx-xx * @brief Use buttons to control lanterns *************************************************** **************************** * @attention * * Experimental platform: Wildfire STM32 F429 development board * Forum: http://www.firebbs.cn * Taobao: https://fire-stm32.taobao.com * *************************************************** **************************** */ #include “stm32f4xx.h” #include “./led/bsp_led.h” #include “./key/bsp_key.h” /** […]

How to obtain the detection index APs of small targets? ——Dataset Yolo format generates json file

It’s such a simple thing, but I worked on it for several days for no reason. I was very depressed, so I just started without saying much. First, you must have a data set in YoLo format. Starting from the simplest, you need image data and corresponding txt tag data of the yolo type. (The […]

Further optimization of the operator speed of the goodFeaturesToTrack function (Harris corner point, Shi-Tomasi corner point detection) in Opencv (the 1920*1080 test image is processed in 11ms). …

I searched for a video de-noising algorithm that works very well. I feel that the effect is quite impressive, but the speed is relatively slow. If it can be done in real time, it will still be of great practical value. So I blindly chose this topic, and the first function I encountered was corner […]

Transformer-based decode target detection framework (modify DETR source code)

Tip: Transformer structure target detection decoder, including loss calculation, with source code attached Article directory Preface 1. Interpretation of main function code 1. Understanding the overall structure 2. Main function code interpretation 3. Source code link 2. Interpretation of decode module code 1. Interpretation of decoded TransformerDec module code 2. Interpretation of decoded TransformerDecoder module […]

Plug-in Analysis|Yaklang SQL Injection Detection Heuristic Algorithm

Background As an old and mature SQL vulnerability scanning tool, sqlmap dominates the field of automated SQL injection detection. Today’s SQL injection detection is often detected through passive scanning, and then further vulnerability confirmation and exploitation is carried out through sqlmap or manual injection. In this case, we need to develop a SQL injection detection […]