Actspotter library for detecting activities
Project description
The actspotter is a library / tensorflow model for detecting activities. It allows to classify body activities in images or videos. The package is limited to videos and images with only one person by design.
The package is currently in early development.
Future plans
Tensorflow model deployment will be integrated soon. Currently this package allows to classify push-ups and pull-ups. In future version kicks and others body activities will follow.
It is also planned to provide a signal processing layer that allows to easily detect connected activites and count them.
Another application will be to integrate with keyboard drivers so that activities could be used for controlling video games (e.g. by kicks).
Installation
Install this library in a virtualenv using pip. virtualenv is a tool to create isolated Python environments. The basic problem it addresses is one of dependencies and versions, and indirectly permissions.
With virtualenv, it’s possible to install this library without needing system install permissions, and without clashing with the installed system dependencies.
Supported Python Versions
Python >= 3.6
Mac/Linux
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install actspotter
Windows
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install actspotter
Example Usage
import cv2
import tensorflow as tf
from actspotter import ImageClassifier, classify_image_input_dimension, class_names
def _resize(frame, dim=classify_image_input_dimension):
frame = cv2.resize(frame, dim, interpolation=cv2.INTER_AREA)
return frame
def _to_tf_array(frame, dim=classify_image_input_dimension):
frame = _resize(frame, dim)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame = tf.convert_to_tensor(frame, dtype=tf.float32)
return frame
images = [
to_tf_array(cv2.imread("test.jpg")),
]
print(class_names)
print(image_classifier.classify_images(images))
import cv2
import tensorflow as tf
from actspotter import VideoClassifier, classify_image_input_dimension
def _resize(frame, dim=classify_image_input_dimension):
return frame
def _to_tf_array(frame, dim=classify_image_input_dimension):
frame = _resize(frame, dim)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame = tf.convert_to_tensor(frame, dtype=tf.float32)
return frame
cap = cv2.VideoCapture(0)
video_classifier = VideoClassifier(buffer_size=4)
video_classifier.start()
while cap.isOpened():
ret, frame = cap.read()
if ret == True:
video_classifier.add_image(to_tf_array(frame))
state = video_classifier.get_last_classification()
print(state)
frame = resize(frame, dim=(600, 600))
cv2.putText(frame, f"{state}", (10, 40), 0, 2, 255)
cv2.imshow("Frame", frame)
waitkey = cv2.waitKey(25) & 0xFF
if waitkey == ord("q"):
break
video_classifier.exit()
cap.release()
cv2.destroyAllWindows()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file actspotter-0.1.0.tar.gz
.
File metadata
- Download URL: actspotter-0.1.0.tar.gz
- Upload date:
- Size: 11.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9a222d4a3c94ca8cb949d5955b0078cb7a2b4279353ed13f0151e3e0ae6f2a2 |
|
MD5 | b786e8e2d9dcfdc7de62d507ad766f88 |
|
BLAKE2b-256 | c4bb9630575eab783cedaf994421cd8b3fd36dcd0fad5e66649d06f6d4b1365c |
File details
Details for the file actspotter-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: actspotter-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 11.9 MB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e51ba9a07f5e48d733fd4a46ade832dd3bb922fd1df86d34cae30809377f98b |
|
MD5 | 539cc9ea4d33fd9718463c4db80bf37b |
|
BLAKE2b-256 | 05fa66b1fb6e92e0eea57478461c501b02790d5a5bacf43b9f615dd96d1438bd |