revile
1.0.0
これは、ロールアウト写真またはスリットスキャンのプリンシパルを使用して、円筒表面の2D画像を生成するための簡単な例パッケージです。
このパッケージには、新しいビデオのキャプチャとビデオストリームの処理という2つの主要な機能があります。また、コマンドラインインターフェイス(CLI)として、またはPythonパッケージとして、2つの形式で使用できます。 CLIスクリプトは、独自のPythonスクリプトでどのように使用できるかの例を示しています。
このコードはテストされており、Linux 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のフレームレートで、20mmバイアルの場合:
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