sketchkit.ordering.LineDrawer.CNNVE package

Submodules

sketchkit.ordering.LineDrawer.CNNVE.CNNVE module

Main animator class for LineDrawer - video-synchronized sketch animation

class sketchkit.ordering.LineDrawer.CNNVE.CNNVE.CNNVE(device: str = 'cpu')[source]

Bases: object

LineDrawer animation generator that synchronizes strokes with video frames. Renamed to CNNVE to match vectorization structure.

indir

Input directory containing .graph_merge files and videos

Type:

str

_create_linear_curve(p_start, p_end)[source]

Create a linear Curve between two vertices.

_generate_ordered_sketch(msort, point_list_map, height, width)[source]

Generate a single Sketch object with paths ordered by frame appearance.

_point_to_vertex(p)[source]

Convert [y, x] point to Vertex(x, y).

_points_to_path(points)[source]

Convert list of [y, x] points to a Path.

_vis_merge_result_paints_undo(im_ori_c1, merge_dic, video_path)[source]

Visualize stroke merging with video synchronization.

Parameters:
  • im_ori_c1 – Original image

  • merge_dic – Merge dictionary with stroke data

  • video_path – Path to video file

Returns:

Generated Sketch object

Return type:

Sketch

run(img: ndarray, video_path: str) Sketch[source]

Generate a single Sketch with ordered paths from image and video.

Parameters:
  • img (np.ndarray) – Input image as a 2D numpy array (grayscale).

  • video_path (str) – Path to video file for frame synchronization.

Returns:

Generated Sketch object with paths ordered by drawing sequence.

Return type:

Sketch

sketchkit.ordering.LineDrawer.CNNVE.color_generator module

Color generation utilities for creating visually distinct stroke colors.

class sketchkit.ordering.LineDrawer.CNNVE.color_generator.ColorGenerator(use_hsluv=True)[source]

Bases: object

Generate perceptually distinct colors for stroke visualization.

_color_gene_hsluv()[source]

Generate colors using HSLuv color space for better perceptual uniformity.

Returns:

List of RGB color arrays

Return type:

list

_gene_css4_cmap()[source]

Generate colors from CSS4 color palette.

Returns:

List of RGB color tuples

Return type:

list

get_color_map()[source]

Get a list of distinct colors for visualization.

Returns:

List of RGB color tuples

Return type:

list

sketchkit.ordering.LineDrawer.CNNVE.frame_matcher module

Frame matching utilities for synchronizing strokes with video frames.

class sketchkit.ordering.LineDrawer.CNNVE.frame_matcher.FrameMatcher[source]

Bases: object

Match extracted strokes to video frames based on overlap.

match_strokes_to_frames(m_list, ref_frames, size)[source]

Match each stroke to the video frame where it first appears.

Parameters:
  • m_list – Dictionary of stroke masks

  • ref_frames – List of reference video frames

  • size – Image size tuple (h, w)

Returns:

Dictionary mapping frame indices to lists of strokes

Return type:

dict

sketchkit.ordering.LineDrawer.CNNVE.video_processor module

Video processing utilities for extracting and filtering frames from MP4 files.

class sketchkit.ordering.LineDrawer.CNNVE.video_processor.VideoProcessor[source]

Bases: object

Process video files to extract and filter frames.

imgs_to_mask(indir, linedrawing=None)[source]

Load and filter image frames from directory.

Parameters:
  • indir – Directory with frames

  • linedrawing – Reference final image

Returns:

Filtered frames

Return type:

list

mp4_to_imgs(src_mp4, b_gt, ref)[source]

Extract frames from MP4 file.

Parameters:
  • src_mp4 – Path to MP4 file

  • b_gt – Whether to use ground truth

  • ref – Reference image

Returns:

Filtered frames

Return type:

list

sketchkit.ordering.LineDrawer.CNNVE.video_processor.add_pil_border(original_image, border_width=3, border_color=(255, 0, 0))[source]

Adds a colored border to a PIL Image.

Parameters:
  • original_image – PIL Image

  • border_width – Border width in pixels

  • border_color – RGB color tuple

Returns:

PIL Image with border

sketchkit.ordering.LineDrawer.CNNVE.video_processor.get_match(images, indir)[source]

Filters frames to find key frames in drawing process.

Parameters:
  • images – List of image frames

  • indir – Output directory

Returns:

Filtered key frames

Return type:

list

sketchkit.ordering.LineDrawer.CNNVE.video_processor.is_increasing_relation(imgA, imgB)[source]

Checks if imgB is an “increasing” version of imgA.

Parameters:
  • imgA – Previous image

  • imgB – Next image

Returns:

True if B includes most of A

Return type:

bool

Module contents

class sketchkit.ordering.LineDrawer.CNNVE.CNNVE(device: str = 'cpu')[source]

Bases: object

LineDrawer animation generator that synchronizes strokes with video frames. Renamed to CNNVE to match vectorization structure.

indir

Input directory containing .graph_merge files and videos

Type:

str

_create_linear_curve(p_start, p_end)[source]

Create a linear Curve between two vertices.

_generate_ordered_sketch(msort, point_list_map, height, width)[source]

Generate a single Sketch object with paths ordered by frame appearance.

_point_to_vertex(p)[source]

Convert [y, x] point to Vertex(x, y).

_points_to_path(points)[source]

Convert list of [y, x] points to a Path.

_vis_merge_result_paints_undo(im_ori_c1, merge_dic, video_path)[source]

Visualize stroke merging with video synchronization.

Parameters:
  • im_ori_c1 – Original image

  • merge_dic – Merge dictionary with stroke data

  • video_path – Path to video file

Returns:

Generated Sketch object

Return type:

Sketch

run(img: ndarray, video_path: str) Sketch[source]

Generate a single Sketch with ordered paths from image and video.

Parameters:
  • img (np.ndarray) – Input image as a 2D numpy array (grayscale).

  • video_path (str) – Path to video file for frame synchronization.

Returns:

Generated Sketch object with paths ordered by drawing sequence.

Return type:

Sketch