Skip to content

Commit

Permalink
capture images on demand.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhashim6 committed Feb 29, 2020
1 parent c5a0da5 commit 2c9d6f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from concurrent.futures import ThreadPoolExecutor
import queue
from bluetooth import BluetoothConnection
from camera_scenes_feed import run_video_cam
from camera_feed import run_video_cam, capture
from io_types import *
from object_detection.objectDetection_lite import detect as detect_objects
import time
Expand Down Expand Up @@ -43,8 +43,8 @@ def process_tasks(remote: BluetoothConnection):
log('MODE_CHANGE_EMOTIONS')
elif change_type == MODE_CHANGE_OBJECT_DETECTION:
log('MODE_CHANGE_OBJECT_DETECTION')
objs = pretty_objects(detect_objects(current_frame))
log('object detection results:\n', json_of_result(RESULT_OBJECT_DETECTION, objs))
objs = pretty_objects(detect_objects(capture()))
log('object detection results: ', objs)
remote.send(json_of_result(RESULT_OBJECT_DETECTION, objs))
log("process: ", task)

Expand Down
10 changes: 7 additions & 3 deletions camera_scenes_feed.py → camera_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
from scenedetect.detectors import ContentDetector
from typing import Callable

cam = cv2.VideoCapture(0)


def capture():
return cam.read()[1]


def run_video_cam(on_new_scene: Callable):
cam = cv2.VideoCapture(0)
_, first_scene = cam.read()
on_new_scene(first_scene)
on_new_scene(capture())
scene_manager = SceneManager()
scene_manager.add_detector(ContentDetector())
scene_manager.detect_scenes(frame_source=cam, callback=on_new_scene)
Expand Down

0 comments on commit 2c9d6f7

Please sign in to comment.