Skip to main content

用于检测活动的 Actspotter 库

项目描述

actpotter是一个用于检测活动的库/张量流模型。它允许对图像或视频中的身体活动进行分类。该套餐仅限于设计为只有一个人的视频和图像。

提供以下课程:

  • 没有任何

  • pull_up_up

  • pull_up_down

  • pull_up_none

  • push_up_up

  • push_up_down

  • push_up_none

  • 坐起来

  • 坐下

  • 坐下无

该软件包目前处于早期开发阶段。

未来的计划

TensorFlow 模型部署将很快集成。目前,该软件包允许对俯卧撑、仰卧起坐和引体向上进行分类。在未来的版本中,踢球和其他身体活动将随之而来。

它还计划提供一个信号处理层,可以轻松检测连接的活动并对其进行计数。

另一个应用程序将与键盘驱动程序集成,以便可以使用活动来控制视频游戏(例如通过踢球)。

安装

使用 pip在vi​​rtualenv中安装这个库。virtualenv是一个创建隔离 Python 环境的工具。它解决的基本问题是依赖关系和版本之一,以及间接权限。

使用virtualenv,可以在不需要系统安装权限的情况下安装这个库,并且不会与已安装的系统依赖项发生冲突。

支持的 Python 版本

蟒蛇> = 3.6

Mac/Linux

pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install actspotter

视窗

pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install actspotter

示例用法

要求:已安装 cv2 (opencv)。

图片分类:

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()

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

actpotter-0.1.3.tar.gz (11.8 MB 查看哈希)

已上传 source

内置分布

actpotter-0.1.3-py2.py3-none-any.whl (11.9 MB 查看哈希)

已上传 py2 py3