Skip to content

Commit

Permalink
updated hand example and testing code
Browse files Browse the repository at this point in the history
  • Loading branch information
rishi23root committed Apr 22, 2024
1 parent 688e031 commit 984d4e4
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 57 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ def all_actions(**kwargs):
kwargs = all_actions()
```

![image](https://rishi23root.github.io/opencv_wrap/static/Screenshot-20240422075128-1152x666.png)

> **Example 3** : Reading video and detecting Pose in each frame
```python
Expand Down Expand Up @@ -245,6 +247,8 @@ def all_actions(**kwargs):
all_actions()
```

![image](https://rishi23root.github.io/opencv_wrap/static/Screenshot%20from%202024-04-22%2007-42-13.png)

> **Example 4** : Reading video and saving each frame in a folder
```python
Expand Down Expand Up @@ -276,8 +280,7 @@ def all_actions(**kwargs):
all_actions()
```

![image](https://rishi23root.github.io/opencv_wrap/static/Screenshot-20240416071956-1175x661.png)
---
## ![image](https://rishi23root.github.io/opencv_wrap/static/Screenshot-20240416071956-1175x661.png)

# Future Updates

Expand Down
51 changes: 50 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,55 @@
"Programming Language :: Python :: 3.10",
],
packages=find_packages(),
install_requires=['absl-py>=2.1.0', 'attrs>=23.2.0', 'cffi>=1.16.0', 'contourpy>=1.2.1', 'cycler>=0.12.1', 'filelock>=3.13.4', 'flatbuffers>=24.3.25', 'fonttools>=4.51.0', 'fsspec>=2024.3.1', 'jax>=0.4.26', 'jaxlib>=0.4.26', 'Jinja2>=3.1.3', 'kiwisolver>=1.4.5', 'MarkupSafe>=2.1.5', 'matplotlib>=3.8.4', 'mediapipe>=0.10.11', 'ml-dtypes>=0.4.0', 'mpmath>=1.3.0', 'networkx>=3.3', 'numpy>=1.26.4', 'nvidia-cublas-cu12>=12.1.3.1', 'nvidia-cuda-cupti-cu12>=12.1.105', 'nvidia-cuda-nvrtc-cu12>=12.1.105', 'nvidia-cuda-runtime-cu12>=12.1.105', 'nvidia-cudnn-cu12>=8.9.2.26', 'nvidia-cufft-cu12>=11.0.2.54', 'nvidia-curand-cu12>=10.3.2.106', 'nvidia-cusolver-cu12>=11.4.5.107', 'nvidia-cusparse-cu12>=12.1.0.106', 'nvidia-nccl-cu12>=2.19.3', 'nvidia-nvjitlink-cu12>=12.4.127', 'nvidia-nvtx-cu12>=12.1.105', 'opencv-contrib-python>=4.9.0.80', 'opencv-python>=4.9.0.80', 'opt-einsum>=3.3.0', 'packaging>=24.0', 'pillow>=10.3.0', 'protobuf>=3.20.3', 'pycparser>=2.22', 'pyparsing>=3.1.2', 'python-dateutil>=2.9.0.post0', 'scipy>=1.13.0', 'six>=1.16.0', 'sounddevice>=0.4.6', 'sympy>=1.12', 'torch>=2.2.2', 'triton>=2.2.0', 'typing_extensions>=4.11.0'],
install_requires=[
"absl-py>=2.1.0",
"attrs>=23.2.0",
"cffi>=1.16.0",
"contourpy>=1.2.1",
"cycler>=0.12.1",
"filelock>=3.13.4",
"flatbuffers>=24.3.25",
"fonttools>=4.51.0",
"fsspec>=2024.3.1",
"jax>=0.4.26",
"jaxlib>=0.4.26",
"Jinja2>=3.1.3",
"kiwisolver>=1.4.5",
"MarkupSafe>=2.1.5",
"matplotlib>=3.8.4",
"mediapipe>=0.10.11",
"ml-dtypes>=0.4.0",
"mpmath>=1.3.0",
"networkx>=3.3",
"numpy>=1.26.4",
"nvidia-cublas-cu12>=12.1.3.1",
"nvidia-cuda-cupti-cu12>=12.1.105",
"nvidia-cuda-nvrtc-cu12>=12.1.105",
"nvidia-cuda-runtime-cu12>=12.1.105",
"nvidia-cudnn-cu12>=8.9.2.26",
"nvidia-cufft-cu12>=11.0.2.54",
"nvidia-curand-cu12>=10.3.2.106",
"nvidia-cusolver-cu12>=11.4.5.107",
"nvidia-cusparse-cu12>=12.1.0.106",
"nvidia-nccl-cu12>=2.19.3",
"nvidia-nvjitlink-cu12>=12.4.127",
"nvidia-nvtx-cu12>=12.1.105",
"opencv-contrib-python>=4.9.0.80",
"opencv-python>=4.9.0.80",
"opt-einsum>=3.3.0",
"packaging>=24.0",
"pillow>=10.3.0",
"protobuf>=3.20.3",
"pycparser>=2.22",
"pyparsing>=3.1.2",
"python-dateutil>=2.9.0.post0",
"scipy>=1.13.0",
"six>=1.16.0",
"sounddevice>=0.4.6",
"sympy>=1.12",
"torch>=2.2.2",
"triton>=2.2.0",
"typing_extensions>=4.11.0",
],
zip_safe=False,
)
Binary file added static/Screenshot-20240422075128-1152x666.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
107 changes: 53 additions & 54 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# flake8: noqa: E501
from opencv_wrap import cv2Decorator
import cv2
from opencv_wrap.detectors import Face , Hand, Pose
from opencv_wrap.detectors import Face, Hand, Pose
from opencv_wrap.utils.helper import saveFrame, detectionBox, show_all_frames, clipImage


Expand All @@ -27,14 +27,14 @@
# reading a video from the directory


# face detection
# face detection
# @cv2Decorator.DetectInEachFrame(
# detector=Face(verbose=True),
# name="face",
# )
# @cv2Decorator.TotalTimeTaken(show=True)
# # @cv2Decorator.AccessCamOrVideo(show=False, videoPath="./opencv_wrap/testMedia/test.mp4", fps=12)
# @cv2Decorator.AccessCamOrVideo(show=False, fps=12)
# @cv2Decorator.AccessCamOrVideo(show=False)
# @cv2Decorator.CalculateFps(draw=True)
# @cv2Decorator.MirrorFrame()
# @cv2Decorator.ConvertCOLOR(converter=cv2.COLOR_BGR2GRAY)
Expand Down Expand Up @@ -63,65 +63,65 @@
# kwargs = all_actions()



# Hand
# @cv2Decorator.DetectInEachFrame(
# detector=Hand(verbose=True),
# name="face",
# )
# @cv2Decorator.TotalTimeTaken(show=True)
# # @cv2Decorator.AccessCamOrVideo(show=False, videoPath="./opencv_wrap/testMedia/test.mp4", fps=12)
# @cv2Decorator.AccessCamOrVideo(show=False, fps=12)
# @cv2Decorator.CalculateFps(draw=True)
# @cv2Decorator.MirrorFrame()
# @cv2Decorator.ConvertCOLOR(converter=cv2.COLOR_BGR2GRAY)
# @cv2Decorator.ConvertCOLOR(converter=cv2.COLOR_RGB2BGR, frameName="bgr_frame")
# def all_actions(**kwargs):
# # detect face from trainerd data and detectMultiScale use to deteat every size of face
# # face_coordinate = kwargs["face"].detectMultiScale(kwargs["greyScale"], 1.3, 5)
# mainFrameCopy = kwargs["frame"].copy()
# processed = kwargs["face"].detect(kwargs["bgr_frame"])
# face_coordinate = kwargs["face"].getDetectionBox(
# processed, kwargs["frame"], draw=True
# )
# kwargs["face"].getLandmarks(processed, kwargs["frame"],draw=True)
# # print(len(face_coordinate))

# kwargs["detected"] = [clipImage(mainFrameCopy, i) for i in face_coordinate]
# # saveFrame(frame=frame,count=kwargs['frame_count'],destination='./test2')

# # detectionBox(detectedArr=face_coordinate, frame=kwargs["frame"])
# # show_all_frames(kwargs,keysToShow=['frame','greyScale','mirror_frame','detected'])
# # show_all_frames(kwargs,keysToShow=['frame','greyScale','mirror_frame'])
# show_all_frames(kwargs, keysToShow=["frame", "detected"])
# return kwargs
@cv2Decorator.DetectInEachFrame(
detector=Hand(verbose=True),
name="hand",
)
@cv2Decorator.TotalTimeTaken(show=True)
# @cv2Decorator.AccessCamOrVideo(show=False, videoPath="./opencv_wrap/testMedia/test.mp4", fps=12)
@cv2Decorator.AccessCamOrVideo(show=False, fps=12)
@cv2Decorator.CalculateFps(draw=True)
@cv2Decorator.MirrorFrame()
@cv2Decorator.ConvertCOLOR(converter=cv2.COLOR_BGR2GRAY)
@cv2Decorator.ConvertCOLOR(converter=cv2.COLOR_RGB2BGR, frameName="bgr_frame")
def all_actions(**kwargs):
# detect hand from trainerd data and detectMultiScale use to deteat every size of hand
# face_coordinate = kwargs["hand"].detectMultiScale(kwargs["greyScale"], 1.3, 5)
mainFrameCopy = kwargs["frame"].copy()
processed = kwargs["hand"].detect(kwargs["bgr_frame"])
face_coordinate = kwargs["hand"].getDetectionBox(
processed, kwargs["frame"], draw=True
)
kwargs["hand"].getLandmarks(processed, kwargs["frame"], draw=True)
# print(len(face_coordinate))

kwargs["detected"] = [clipImage(mainFrameCopy, i) for i in face_coordinate]
# saveFrame(frame=frame,count=kwargs['frame_count'],destination='./test2')

# detectionBox(detectedArr=face_coordinate, frame=kwargs["frame"])
# show_all_frames(kwargs,keysToShow=['frame','greyScale','mirror_frame','detected'])
# show_all_frames(kwargs,keysToShow=['frame','greyScale','mirror_frame'])
show_all_frames(kwargs, keysToShow=["frame", "detected"])
return kwargs


# kwargs = all_actions()
kwargs = all_actions()


# pose detection


# @cv2Decorator.DetectInEachFrame(
# detector=Pose(verbose=True),
# name="face",
# name="pose",
# )
# @cv2Decorator.TotalTimeTaken(show=True)
# # @cv2Decorator.AccessCamOrVideo(show=False, videoPath="./opencv_wrap/testMedia/test.mp4", fps=12)
# @cv2Decorator.AccessCamOrVideo(show=False, fps=12)
# @cv2Decorator.AccessCamOrVideo(show=False, videoPath="./opencv_wrap/testMedia/test.mp4", fps=12)
# # @cv2Decorator.AccessCamOrVideo(show=False, fps=12)
# @cv2Decorator.CalculateFps(draw=True)
# @cv2Decorator.MirrorFrame()
# @cv2Decorator.ConvertCOLOR(converter=cv2.COLOR_BGR2GRAY)
# @cv2Decorator.ConvertCOLOR(converter=cv2.COLOR_RGB2BGR, frameName="bgr_frame")
# def all_actions(**kwargs):
# # detect face from trainerd data and detectMultiScale use to deteat every size of face
# # face_coordinate = kwargs["face"].detectMultiScale(kwargs["greyScale"], 1.3, 5)
# # detect pose from trainerd data and detectMultiScale use to deteat every size of pose
# # face_coordinate = kwargs["pose"].detectMultiScale(kwargs["greyScale"], 1.3, 5)
# mainFrameCopy = kwargs["frame"].copy()
# processed = kwargs["face"].detect(kwargs["bgr_frame"])
# face_coordinate = kwargs["face"].getDetectionBox(
# processed = kwargs["pose"].detect(kwargs["bgr_frame"])
# face_coordinate = kwargs["pose"].getDetectionBox(
# processed, kwargs["frame"], draw=True
# )
# kwargs["face"].getLandmarks(processed, kwargs["frame"],draw=True)
# kwargs["pose"].getLandmarks(processed, kwargs["frame"], draw=True)
# # print(len(face_coordinate))

# kwargs["detected"] = [clipImage(mainFrameCopy, i) for i in face_coordinate]
Expand All @@ -134,7 +134,7 @@
# return kwargs


# kwargs = all_actions()
# all_actions()


# reading the cam feed
Expand All @@ -156,15 +156,14 @@
# print(a['frame_count'])



# show converted frames in smart view
@cv2Decorator.TotalTimeTaken(show=True)
@cv2Decorator.AccessCamOrVideo(show=False, videoPath="./opencv_wrap/testMedia/test.mp4", fps=12)
@cv2Decorator.CalculateFps(draw=True)
@cv2Decorator.MirrorFrame()
@cv2Decorator.ConvertCOLOR(converter=cv2.COLOR_BGR2GRAY)
def all_actions(**kwargs):
show_all_frames(kwargs,keysToShow=['frame','greyScale','mirror_frame'])
return kwargs
# @cv2Decorator.TotalTimeTaken(show=True)
# @cv2Decorator.AccessCamOrVideo(show=False, videoPath="./opencv_wrap/testMedia/test.mp4", fps=12)
# @cv2Decorator.CalculateFps(draw=True)
# @cv2Decorator.MirrorFrame()
# @cv2Decorator.ConvertCOLOR(converter=cv2.COLOR_BGR2GRAY)
# def all_actions(**kwargs):
# show_all_frames(kwargs,keysToShow=['frame','greyScale','mirror_frame'])
# return kwargs

all_actions()
# all_actions()

0 comments on commit 984d4e4

Please sign in to comment.