Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# slitscan
Python video slit scan generator based on OpenCV

Generates a color strip of a given image sequence and returns the result as image object.

Using OpenCV, this function creates a color slit scan from the given input
file. By default, the average color of 5 frames is condensed into one stripe
in the output image.

If you encounter errors, this is probably due to unsupported video formats.
Check if your Python OpenCV bindings are compiled using ffmpeg. If not,
you have to manually compile OpenCV with Python bindings including ffmpeg.
This is usually true for Linux and OS X because the PyPi installed OpenCV
bindings do not support ffmpeg for these plattforms. The Windows version
does support ffmpeg, but with the limitation of LGPL licensed code. If
in doubt, convert your video to uncrompressed AVI or comparable.

Testet with Python 3.6, should work back to 2.7, too. After installation, use the command line phrase "slitscan -h" to learn about the features.

## Installing
### Mac
If not already done: `brew install python3`

Then: `pip3 install git+https://github.com/0xLeon/slitscan.git`

### Other (e.g. Windows)

First search on Google about installing _python (3.6)_ and _pip_!

Then: `pip install git+https://github.com/0xLeon/slitscan.git`

## Using
slitscan --help

### Usage & Arguments
slitscan [-h] [--outfile OUTFILE] [--height HEIGHT] [--frame-aggr FRAME_AGGR] INFILE

### Optional argument definition

-h, --help

show this help message and exit


--outfile OUTFILE

Output file name relative to input file, can be specified absolute


--height HEIGHT

Height of the output slit scan image


--frame-aggr FRAME_AGGR

Number of frames to aggregate into one stipe

## Feel free to contribute!
This is a new script. If you know python, please make the script running more smooth and faster.
### Roadmap:
- parallelisation _for faster and smoother script running_
- progress
- summary
13 changes: 10 additions & 3 deletions src/slitscan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BreakException(Exception):
"""Utility exception used to break out of loops"""
pass

def slitscan(imsequence, height=400, frame_aggr=5):
def slitscan(imsequence, height=400, frame_aggr=5, length=0):
"""Generates a color strip of a given image sequence and returns the result as image object.

Using OpenCV, this function creates a color slit scan from the given input
Expand Down Expand Up @@ -43,13 +43,18 @@ def slitscan(imsequence, height=400, frame_aggr=5):
raise ValueError('Invalid output image height of {:d}'.format(height))

bgr = []
prog= 0

print('Reading frames')
print ('Reading ', length, ' frames')

try:
while imsequence.isOpened():
bgrLocal = np.array([0, 0, 0], dtype=np.float)
c = 0
prog = prog + 1
perc = prog / length * 100

print('reading frame {:} / {:} [{:0.2f}%]'.format(prog, length, perc))

for i in range(0, frame_aggr):
try:
Expand Down Expand Up @@ -104,7 +109,9 @@ def slitscanf(infile, height=400, frame_aggr=5, outfile=None):

cap = cv2.VideoCapture(infile)

im = slitscan(cap, height, frame_aggr)
length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))

im = slitscan(cap, height, frame_aggr, length)

cv2.imwrite(outfile, im)

Expand Down