Author:KuoYuan Li
wrap the javascript code to handle image from webcam in colab
本package提供一系列在 colab 中操作webcam的方法
在colab中使用之前請先進行安裝
!pip install colabcam
webcam 拍照存檔
(take a photo from webcam and save to 1.jpg)
import colabcam
colabcam.take_photo("1.jpg")
動態顯示人臉框及文字(cv2只支援英數字)
(demo with mediapipe face_detection)
#Note:bbox(人臉框)是另外疊加顯示的,速度會有延遲是正常的
import mediapipe as mp
import colabcam
import numpy as np
import cv2
mp_face_detection = mp.solutions.face_detection
face_detection = mp_face_detection.FaceDetection()
# start streaming video from webcam
colabcam.video_stream()
# label for video
label_html = '顯示中...(點擊畫面以結束顯示)'
# initialze bounding box to empty
bbox = ''
while True:
js_reply = colabcam.video_frame(label_html, bbox)
if not js_reply:break
# convert JS response to OpenCV Image
img = colabcam.js_to_image(js_reply["img"])
results = face_detection.process(img)
frame_height,frame_width=np.shape(img)[0:2]
overlapImg = np.zeros([frame_height,frame_width,4], dtype=np.uint8)
if results.detections:
for detection in results.detections:
box = detection.location_data.relative_bounding_box
x, y, w, h =int(box.xmin*frame_width),int(box.ymin*frame_height), \
int(box.width*frame_width),int(box.height*frame_height)
if w>0 and h>0:
overlapImg = cv2.rectangle(overlapImg,(x,y),(x+w,y+h),(255,0,0),2)
cv2.putText(overlapImg,'text test',(x,y-20),cv2.FONT_HERSHEY_SIMPLEX,1,(255,0,0),2)
bbox = colabcam.cvImg2bbox(overlapImg)
License
MIT
Metadata
Release files for colabcam 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| colabcam-1.0.3.tar.gz | 5.4 kB | Without provenance | Details for colabcam-1.0.3.tar.gz |
Release files / colabcam-1.0.3.tar.gz
| Download URL | colabcam-1.0.3.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
18ab3e407bf23bd0c044a45dd5010191b2551b40d57ede1ccbff65365026e1d6
|
|
BLAKE2b-256 checksum How to use checksums |
4c40825fa07131d01c42078c314f0b87006ab1e231e8aa946e6ec3f86cef1cd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.8
|
Security for colabcam 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.