# Path: util/visualize.py
# def check_point(cur_x, cur_y, minx, miny, maxx, maxy):
#     return minx < cur_x < maxx and miny < cur_y < maxy
# 
# def _npcircle(image, cx, cy, radius, color, transparency=0.0):
#     """Draw a circle on an image using only numpy methods."""
#     radius = int(radius)
#     cx = int(cx)
#     cy = int(cy)
#     y, x = np.ogrid[-radius: radius, -radius: radius]
#     index = x**2 + y**2 <= radius**2
#     image[cy-radius:cy+radius, cx-radius:cx+radius][index] = (
#         image[cy-radius:cy+radius, cx-radius:cx+radius][index].astype('float32') * transparency +
#         np.array(color).astype('float32') * (1.0 - transparency)).astype('uint8')
# 
# Path: util/visualize.py
# def _npcircle(image, cx, cy, radius, color, transparency=0.0):
# def check_point(cur_x, cur_y, minx, miny, maxx, maxy):
# def visualize_joints(image, pose):
# def show_heatmaps(cfg, img, scmap, pose, cmap="jet"):
# def show_arrows(cfg, img, pose, arrows):
# def waitforbuttonpress():


import math
import numpy as np
import scipy.spatial
import matplotlib.pyplot as plt
import munkres
from util.visualize import check_point, _npcircle
from util import visualize

        self.prev_person_conf = person_conf
        self.prev_color_assignment = color_assignment



keypoint_colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (0, 255, 255), (255, 0, 255), (255, 255, 0),
                   (255, 0, 0), (0, 255, 0), (0, 0, 255), (0, 255, 255), (255, 0, 255), (255, 255, 0),
                   (255, 0, 0), (0, 255, 0), (255, 0, 0), (0, 255, 0), (0, 0, 255)]

def visualize_detections(cfg, img, detections):
    vis_scale = 1.0
    marker_size = 4

    minx = 2 * marker_size
    miny = 2 * marker_size
    maxx = img.shape[1] - 2 * marker_size
    maxy = img.shape[0] - 2 * marker_size

    unPos = detections.coord
    joints_to_visualise = range(cfg.num_joints)
    visim_dets = img.copy()
    for pidx in joints_to_visualise:
        for didx in range(unPos[pidx].shape[0]):
            cur_x = unPos[pidx][didx, 0] * vis_scale
            cur_y = unPos[pidx][didx, 1] * vis_scale

            # / cfg.global_scale

            if check_point(cur_x, cur_y, minx, miny, maxx, maxy):

# Path: util/visualize.py
# def check_point(cur_x, cur_y, minx, miny, maxx, maxy):
#     return minx < cur_x < maxx and miny < cur_y < maxy
# 
# def _npcircle(image, cx, cy, radius, color, transparency=0.0):
#     """Draw a circle on an image using only numpy methods."""
#     radius = int(radius)
#     cx = int(cx)
#     cy = int(cy)
#     y, x = np.ogrid[-radius: radius, -radius: radius]
#     index = x**2 + y**2 <= radius**2
#     image[cy-radius:cy+radius, cx-radius:cx+radius][index] = (
#         image[cy-radius:cy+radius, cx-radius:cx+radius][index].astype('float32') * transparency +
#         np.array(color).astype('float32') * (1.0 - transparency)).astype('uint8')
# 
# Path: util/visualize.py
# def _npcircle(image, cx, cy, radius, color, transparency=0.0):
# def check_point(cur_x, cur_y, minx, miny, maxx, maxy):
# def visualize_joints(image, pose):
# def show_heatmaps(cfg, img, scmap, pose, cmap="jet"):
# def show_arrows(cfg, img, pose, arrows):
# def waitforbuttonpress():


# Path: multiperson/visualize.py
import math
import numpy as np
import scipy.spatial
import matplotlib.pyplot as plt
import munkres
from util.visualize import check_point, _npcircle
from util import visualize


        self.prev_person_conf = person_conf
        self.prev_color_assignment = color_assignment



keypoint_colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (0, 255, 255), (255, 0, 255), (255, 255, 0),
                   (255, 0, 0), (0, 255, 0), (0, 0, 255), (0, 255, 255), (255, 0, 255), (255, 255, 0),
                   (255, 0, 0), (0, 255, 0), (255, 0, 0), (0, 255, 0), (0, 0, 255)]

def visualize_detections(cfg, img, detections):
    vis_scale = 1.0
    marker_size = 4

    minx = 2 * marker_size
    miny = 2 * marker_size
    maxx = img.shape[1] - 2 * marker_size
    maxy = img.shape[0] - 2 * marker_size

    unPos = detections.coord
    joints_to_visualise = range(cfg.num_joints)
    visim_dets = img.copy()
    for pidx in joints_to_visualise:
        for didx in range(unPos[pidx].shape[0]):
            cur_x = unPos[pidx][didx, 0] * vis_scale
            cur_y = unPos[pidx][didx, 1] * vis_scale

            # / cfg.global_scale

            if check_point(cur_x, cur_y, minx, miny, maxx, maxy):

                _npcircle(visim_dets,