revile
1.0.0
這是一個簡單的示例軟件包,用於使用推出攝影或縫隙掃描的主體來生成圓柱體表面的2D圖像。
該軟件包具有兩個主要功能:捕獲新視頻和處理視頻流。它也可以以兩種形式使用:作為命令行接口(CLI)或python軟件包。 CLI腳本顯示瞭如何在您自己的Python腳本中使用它的示例。
該代碼僅經過測試並確認可以在Linux OS上使用,但可能對其他OS起作用。
使用PIP安裝:
pip install git+git://github.com/NaturalHistoryMuseum/revile.git#egg=revile
相機需要從A /dev/video
設備進行流式傳輸。所有攝像機都可能不可能。檢查您的規格。對於通過USB連接具有預覽模式的相機,您可以使用v4l2loopback
進行此操作。安裝v4l2loopback
:
modprobe v4l2loopback
find /dev -name ' video* ' | sort | tail -n 1 # to find the device
gphoto2 --stdout --capture-movie | ffmpeg -i - -vcodec rawvideo -pix_fmt yuv420p -threads 8 -r 60 -f v4l2 /dev/video[DEVICE NUMBER HERE]
revile video --help
Usage: revile video [OPTIONS]
Takes a video and spins the motor at the same time, then processes the
frames of the video file.
Options:
-l, --length INTEGER The length of the video/rotation (in seconds).
--servo Use a servo instead of a stepper motor
-o, --outputdir TEXT
-r, --rotation INTEGER angle (in degrees clockwise) of the camera from
horizontal ; will be rounded to the nearest multiple
of 90
例如,創建和處理20次視頻,然後將其保存在/data/videos
中:
revile video --length 20 --outputdir /data/videos
revile stream --help
Usage: revile stream [OPTIONS]
Uses the preview frames from a camera connected in USB mode to create the
image.
Options:
-f, --frames INTEGER The number of frames to capture (also ; the width of
the final image).
--stream-port INTEGER The /dev/video device to read from.
--servo Use a servo instead of a stepper motor
例如,使用設備/dev/video1
創建和處理500幀:
revile stream --frames 500 --stream-port 1
revile estimate --help
Usage: revile estimate [OPTIONS] DIAMETER
Estimate the optimum length of rotation in frames and seconds.
Options:
-l, --focal-length INTEGER Focal length in mm
-x, --frame-x INTEGER Size of the image/frame across the x axis of the
vial (i.e. width if shooting landscape, height
if portrait) in pixels
-s, --sensor-x INTEGER Size of the sensor across the x axis of the vial
(i.e. width if shooting landscape, height if
portrait) in mm
-w, --ppmm INTEGER Approximate width of 1mm, in pixels, at the
centre of rotation
-r, --fps INTEGER Stream/video framerate
例如,焦距為100mm,框架寬度為720px,傳感器寬度為24mm,寬度為21px的1mm寬度和60fps的Framerate,適用於20mm VIAL:
revile estimate -l 100 -x 720 -s 24 -w 21 -r 60 20
Try 23.6 seconds or 1419 frames:
revile video --length 23.6
revile stream --frames 1419
處理視頻文件/流沒有其他要求。
revile process --help
Usage: revile process [OPTIONS] FILEPATH
Options:
-r, --rotate INTEGER angle (in degrees clockwise) of the image from
horizontal ; will be rounded to the nearest multiple of
90
-o, --outputdir TEXT A directory to save the files to
例如處理examplevideo.mov
,以肖像為導向拍攝,然後輸出到/data/revile/
:
revile process examplevideo.mov -r 270 -o /data/revile