ANY (niAei visioN librarY) is a small library using mediapipe and opencv to manage detection.
It can handle Face and Hand detection. It consists of two parts.
SourceDetector
Source is referred to collection of objects such as Camera or Image. This kind of objects can be expended only
must for a Source object is that the image data must be stored in source.data. So other objects can read image data
and do operations.
ImageCamera
Image can read data from disk and stores the data in self.data.
fromanyimportImageimage=Image(r"wll-asl.jpg")
image.show()Simular to Image, Camera stores the data in self.data, the difference is that Camera will read from a device and not
disk.
fromanyimportCameracamera=Camera(0)
camera.start()
camera.toggle_show()Detector is referred to collection of objects such as Hand or Face. This kind of objects can be expended only
must for a Detector object is that it must contain a detect method. This method must return pandasDataFrame.
HandFacePose
The Hand class uses mediapipe and can detect hands on a source.
fromanyimportImage, Handimage=Image(r"wll-asl.jpg")
hand=Hand(image)
image.draw_pints=hand.detect()
image.show()Here we can see the hand detector was executed on an Image source.
The Face class uses mediapipe and can detect faces on a source.
fromanyimportCamera, Facecamera=Camera(0)
camera.start()
camera.toggle_show()
face=Face(camera)
whileTrue:
camera.draw_box=face.detect()Here we can see the face detector was executed on a Camera source.
The Pose class uses mediapipe and can detect poses on a source.
fromanyimportImage, Poseimage=Image(r"body.png")
pose=Pose(image)
image.draw_pints=pose.detect()
image.show()Here we can see the body detector was executed on a Image source.
The SelfieSegmentation class uses mediapipe and can detect person and return a mask. One can use the mask to replace background.
fromanyimportCamera, Image, SelfieSegmentationcamera=Camera(0)
camera.start()
camera.toggle_show()
i=Image("bg.jpg")
ss=SelfieSegmentation(camera, i)
whileTrue:
camera.replace=ss.detect()Here we can see the SelfieSegmentation was executed on a Camera source and background was replaced by an Image.
Any is open source and can be used as GPL-3.0 license allows
Any can be downloaded as:
git clone https://github.com/mshemuni/ANY.git
cd ANYAny has requirements such as:
mediapipe==0.8.11opencv_python==4.6.0.66pandas==1.4.4numpy~=1.23.3
To install:
pip install mediapipe==0.8.11 opencv_python==4.6.0.66 pandas==1.4.4 numpy~=1.23.3or
pip install -r requirements.txtRun the main.py to see the results.
python main.pyMohammad S.Niaei



