<jupyter_start><jupyter_text>Create images from video<jupyter_code>!mkdir video_to_images_output
!ffmpeg -i wetransfer-249f31/IMG_5314.MOV -vf scale=320:-1 -r 10 video_to_images_output/ffout%3d.png<jupyter_output>ffmpeg version 2.8.11-0ubuntu0.16.04.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
  configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --e[...]<jupyter_text>Use first image to recognize the plate number<jupyter_code>alpr = Alpr("eu", "openalpr/config/openalpr.conf", "openalpr/runtime_data")
if not alpr.is_loaded():
     print("Error loading OpenALPR")
     sys.exit(1)
alpr.set_top_n(20)
alpr.set_default_region("md")

results = alpr.recognize_file("video_to_images_output/ffout001.png")
i = 0
for plate in results['results']:
    i += 1
    print("Plate #%d" % i)
    print("   %12s %12s" % ("Plate", "Confidence"))
    for candidate in plate['candidates']:
        prefix = "-"
        if candidate['matches_template']:
            prefix = "*"

        print("  %s %12s%12f" % (prefix, candidate['plate'], candidate['confidence']))

# Call when completely done to release memory
alpr.unload()
top_candidate = plate['candidates'][0]['plate']
top_candidate<jupyter_output><empty_output><jupyter_text>DeepMask<jupyter_code>!mkdir deepmask_output<jupyter_output><empty_output><jupyter_text>Write down bash script for deepmask<jupyter_code>#!. torch/install/bin/torch-activate
%pylab inline
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img = mpimg.imread('video_to_images_output/ffout001.png')
imgplot = plt.imshow(img)
plt.show()
res = mpimg.imread('deepmask_output/res.jpg')
imgplot = plt.imshow(res)
plt.show()
mask = mpimg.imread('deepmask_output/mask_4.jpg')
imgplot = plt.imshow(mask)
plt.show()
mask[mask > 0] = 1
mask3d = np.tile(mask, (3, 1, 1)).transpose(1, 2, 0)
plt.imshow(img * mask3d)
import Image
from scipy.misc import toimage
logo = toimage(img * mask3d)
logoBox = logo.getbbox()
cropped = logo.crop(logoBox)
cropped.save('deepmask_output/cropped_logo.jpg')
test = mpimg.imread('deepmask_output/cropped_logo.jpg')
imgplot = plt.imshow(test)
plt.show()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup