Automatic parking system for automatically identifying drunken driving based on 51 microcontroller alcohol concentration detector

1. Foreword In the past two years, the requirements and difficulty of graduation projects and graduation defenses have continued to increase. Traditional graduation projects lack innovation and highlights, and often fail to meet the requirements for graduation defenses. In the past two years, junior students and junior students have constantly told Senior Xiaohong to do […]

This article teaches you how to use SpireCV for pod control and target detection and tracking.

Function Overview SpireCV-SDK is an edge real-time sensing SDK library specially built for intelligent unmanned systems. It can realize pod control functions and control the drone’s camera and pod, including taking pictures, recording, streaming and other functions, and can save videos. and push streaming, as well as complete target detection, identification and tracking functions. This […]

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 […]