Giter Club home page Giter Club logo

get-stick-bugged-lol's Introduction

get-stick-bugged-lol

A Python module and command-line tool that generates a Get Stick Bugged Lol video from any image.

Example

gsbl python.jpg python.mp4 -r 760 475 -s 0.7

Example GIF

Example video with sound

This script uses pylsd-nova to detect line segments in the image, Pillow to draw the lines as they move to form the stick bug, and MoviePy to create the video.

Requirements

  • Python 3.6 or later (any OS)

Installation

This package can be installed using pip:

pip install get-stick-bugged-lol

Usage

In the terminal

Installing the package will register the gsbl command in the terminal (or you can use python -m gsbl). To use the image input.png to generate the video output.mp4:

gsbl input.png output.mp4

Optional arguments:

  • -h, --help show this help message and exit
  • -r --resolution WIDTH HEIGHT width and height of the video (default: 720 720)
  • --img-bg-color R G B RGB background color while the image is visible (default: 0 0 0)
  • --line-color R G B RGB color of line segments (default: 255 255 211)
  • --line-bg-color R G B RGB background color after image disappears (default: 125 115 119)
  • -s --scale SCALE the image scale passed to the line segment detector. Slightly lowering this may improve results in large images. This does not affect the image scale in the video (try --resolution instead). (default: 0.8)

In a Python script

from PIL import Image
from gsbl.stick_bug import StickBug

# Create the StickBug object
sb = StickBug(Image.open('example.png'))  # parameter can also just be a filepath

# Change some properties if you want
sb.video_resolution = (1280, 720)
sb.lsd_scale = 0.5

# That's it! The video will be generated the first time you access it
video = sb.video  # MoviePy VideoClip

# Or you can just save it
sb.save_video('example.mp4')

# If any settings were changed, the video will be regenerated the next time you access it.
sb.line_color = (128, 0, 255)
video_purple = sb.video

StickBug properties

  • image the source PIL Image. You can set this when initializing StickBug, or at any time by accessing the property. If you want, you can leave this parameter empty while initializing.

  • segments a numpy array of the 9 line segments detected. If the line segment detector hasn't run yet, that's done the first time this is accessed. The line segment detector will run again if any other properties have changed. This can also be set manually if you want. Each row of the array must contain the values [x1, y1, x2, y2, width].

  • video (readonly) the MoviePy VideoClip generated by the script. If the video hasn't been generated yet, that's done the first time this is accessed. The video will be regenerated if any other properties have changed.

  • video_resolution the resolution of the video as a tuple

  • lsd_scale the image scale passed to the line segment detector. Slightly lowering this may improve results in large images. This does not affect the image scale in the video.

  • img_bg_color the background color of the video while the image is visible

  • line_color the color of the line segments in the video

  • line_bg_color the background color of the video after the image disappears

Building

Install the required packages:

pip install -r requirements.txt

Install this package directly:

cd [path to repository]
pip install .

Or build a wheel:

cd [path to repository]
python3 setup.py bdist_wheel

License

This package is available under the MIT License. See LICENSE for more info.

This package makes use of the following external libraries:

get-stick-bugged-lol's People

Contributors

n0spaces avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

get-stick-bugged-lol's Issues

Very cool library.

This library was the basis for my Discord bot. Whilst I use a modified version of it (mainly for extra features in the bot itself) the core generation stuff is still the original code.

I must say, very cool! Thank you for the work you've done on it!

compile lsd

C:\Users\Joe\Desktop\stick>gsbl meme.png output.mp4
Traceback (most recent call last):
File "c:\users\joe\appdata\local\programs\python\python38-32\lib\runpy.py", line 194, in run_module_as_main
return run_code(code, main_globals, None,
File "c:\users\joe\appdata\local\programs\python\python38-32\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\Joe\AppData\Local\Programs\Python\Python38-32\Scripts\gsbl.exe_main
.py", line 4, in
File "c:\users\joe\appdata\local\programs\python\python38-32\lib\site-packages\gsbl_init
.py", line 1, in
from .generator import generate_video_from_image_path as generate_stick_bug
File "c:\users\joe\appdata\local\programs\python\python38-32\lib\site-packages\gsbl\generator.py", line 4, in
from pylsd import lsd
File "c:\users\joe\appdata\local\programs\python\python38-32\lib\site-packages\pylsd_init.py", line 4, in
from .lsd import lsd
File "c:\users\joe\appdata\local\programs\python\python38-32\lib\site-packages\pylsd\lsd.py", line 10, in
from .bindings.lsd_ctypes import lsdlib
File "c:\users\joe\appdata\local\programs\python\python38-32\lib\site-packages\pylsd\bindings_init_.py", line 4, in
from .lsd_ctypes import *
File "c:\users\joe\appdata\local\programs\python\python38-32\lib\site-packages\pylsd\bindings\lsd_ctypes.py", line 51, in
raise ImportError('Cannot load dynamic library. Did you compile LSD?')
ImportError: Cannot load dynamic library. Did you compile LSD?

C:\Users\Joe\Desktop\stick>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.