sksurgeryimage.acquire.video_writer module¶
Write stream of frames to file using OpenCV
-
class
sksurgeryimage.acquire.video_writer.
ThreadedTimestampedVideoWriter
(filename, fps=25, width=640, height=480, codec='MJPG')[source]¶ Bases:
sksurgeryimage.acquire.video_writer.TimestampedVideoWriter
TimestampedVideoWriter that can be run in a thread. Uses Queue.Queue() to store data, which is thread safe.
Frames will be processed as they are added to the queue:
threaded_vw = ThreadedTimestampedVideoWriter(file, fps, w, h) threaded_vw.start()
threaded_vw.add_to_queue(frame, timestamp) threaded_vw.add_to_queue(frame, timestamp) threaded_vw.add_to_queue(frame, timestamp)
threaded_vw.stop()
-
write_frame
(frame, timestamp=None)[source]¶ Add a frame and a timestamp to the queue for writing. Named for consistency with the non-threaded version. Actual writing to disk is done by write_frame_to_disk() :param frame: Image frame :type frame: numpy array :param timestamp: Frame timestamp :type timestamp: datetime.datetime object
-
-
class
sksurgeryimage.acquire.video_writer.
TimestampedVideoWriter
(filename, fps=25, width=640, height=480, codec='MJPG')[source]¶ Bases:
sksurgeryimage.acquire.video_writer.VideoWriter
Class to write images and timestamps to disk, inherits from VideoWriter.
Parameters: - fps – Frames per second to save to disk.
- filename – Filename to save output video to. Timestamp file is “filename + ‘timestamps’”
-
class
sksurgeryimage.acquire.video_writer.
VideoWriter
(filename, fps=25, width=640, height=480, codec='MJPG')[source]¶ Bases:
object
Class to write images to disk using cv2.VideoWriter.
Parameters: - fps – Frames per second to save to disk.
- filename – Filename to save output video to.
- width – width of input frame
- height – height of input frame