|
1 | 1 | def main(): |
2 | 2 | import argparse |
3 | | - import gsbl |
4 | 3 |
|
5 | 4 | parser = argparse.ArgumentParser(prog='gsbl', description="Create a 'get stick bugged lol' video from an image.") |
6 | | - parser.add_argument('input', help='the image file to be used to generate the video (png, jpg, ...)') |
| 5 | + parser.add_argument('input', |
| 6 | + help="the image file to be used to generate the video (png, jpg, ...). For best results, make" |
| 7 | + "sure the image doesn't have any black or white borders surrounding it.") |
7 | 8 | parser.add_argument('output', help='the video file to be generated and saved (mp4, webm, ...)') |
| 9 | + parser.add_argument('-r --resolution', dest='resolution', nargs=2, type=int, default=[720, 720], |
| 10 | + metavar=('WIDTH', 'HEIGHT'), help='width and height of the video (default: 720 720)') |
| 11 | + parser.add_argument('--img-bg-color', dest='img_bg_color', nargs=3, type=int, default=[0, 0, 0], |
| 12 | + metavar=('R', 'G', 'B'), |
| 13 | + help='RGB background color while the image is visible (default: 0 0 0)') |
8 | 14 | parser.add_argument('--line-color', dest='line_color', nargs=3, type=int, default=[255, 255, 211], |
9 | | - metavar=('R', 'G', 'B'), help='RGB color to use for line segments (default: 255 255 211)') |
10 | | - parser.add_argument('--bg-color', dest='bg_color', nargs=3, type=int, default=[125, 115, 119], |
| 15 | + metavar=('R', 'G', 'B'), help='RGB color of line segments (default: 255 255 211)') |
| 16 | + parser.add_argument('--line-bg-color', dest='line_bg_color', nargs=3, type=int, default=[125, 115, 119], |
11 | 17 | metavar=('R', 'G', 'B'), |
12 | | - help='RGB color to use for background after image disappears (default: 125 115 119)') |
| 18 | + help='RGB background color after image disappears (default: 125 115 119)') |
| 19 | + parser.add_argument('-s --scale', dest='lsd_scale', type=float, default=0.8, metavar='SCALE', |
| 20 | + help='the image scale passed to the line segment detector. Slightly lowering this may improve' |
| 21 | + 'results in large images. This does not affect the image scale in the video (try ' |
| 22 | + '--resolution instead). (default: 0.8)') |
13 | 23 |
|
14 | 24 | args = parser.parse_args() |
15 | 25 |
|
16 | | - video = gsbl.generate_stick_bug(args.input, tuple(args.line_color), tuple(args.bg_color)) |
17 | | - gsbl.save_video(video, args.output) |
| 26 | + try: |
| 27 | + from gsbl.stick_bug import StickBug |
| 28 | + except ImportError: |
| 29 | + # if running this file directly while the package isn't installed |
| 30 | + # noinspection PyUnresolvedReferences |
| 31 | + from stick_bug import StickBug |
| 32 | + |
| 33 | + sb = StickBug(img=args.input, video_resolution=args.resolution, lsd_scale=args.lsd_scale, |
| 34 | + img_bg_color=args.img_bg_color, line_color=args.line_color, line_bg_color=args.line_bg_color) |
| 35 | + sb.save_video(args.output) |
18 | 36 |
|
19 | 37 |
|
20 | 38 | if __name__ == '__main__': |
|
0 commit comments