Skip to content

Instantly share code, notes, and snippets.

@chaitanya-lakkundi
Last active August 17, 2025 16:43
Show Gist options
  • Save chaitanya-lakkundi/33fa144dd39fbdb3795bfad6d6707abb to your computer and use it in GitHub Desktop.
Save chaitanya-lakkundi/33fa144dd39fbdb3795bfad6d6707abb to your computer and use it in GitHub Desktop.
Draw Points on Image Using OpenCV
import cv2
import numpy as np
points_str="303,186 304,185 305,185 306,185 307,185 308,185 309,186 310,186 311,185 312,185 313,185 314,185 315,185 316,186 317,187 318,188 319,189 320,190 321,191 322,192 323,193 324,194 325,194 326,193 327,194 328,194 329,194 330,193 331,192 332,191 333,190 334,189 335,188 336,187 337,186 338,186 339,185 340,185 341,186 342,186 343,186 344,186 345,186 346,186 347,186 348,186 349,186 350,186 351,186 352,186 353,186 354,186 355,186 356,186 357,187 358,187 359,186 360,185 361,185 362,185 363,185 364,185 365,185 366,185 367,185 368,186 369,186 370,186 371,186 372,185 373,186 374,185 375,185 376,184 377,185 378,185 379,185 380,185 381,185 382,185 383,185 384,185 385,185 386,185 387,186 388,186 389,187 390,188 391,188 392,188 393,188 394,187 395,187 396,186 397,186 398,186 399,187 400,186 401,185 402,185 403,185 404,185 405,185 406,185 407,186 408,187 409,188 410,187 411,186 412,186 413,186 414,186 415,186 416,186 417,186 418,186 419,186 420,186 421,186 422,186 423,186 424,186 425,186 426,185 427,186 428,186 429,186 430,186 431,187 432,187 433,187 434,186 435,187 436,186 437,185 438,185 439,186 440,187 441,186 442,185 443,186 444,187 445,188 446,188 447,187 448,187 449,187 450,186 451,185 452,185 453,185 454,186 455,187 456,188 457,188 458,187 459,186 460,186 461,185 462,186 463,187 464,187 465,187 466,187 467,187 468,186 469,185 470,186 471,186 472,186 473,186 474,186 475,187 476,187 477,188 478,189 479,190 480,191 481,192 482,193 483,192 484,191 485,190 486,189 487,188 488,187 489,187 490,188 491,188 492,188 493,188 494,189 495,189 496,188 497,187 498,187 499,187 500,187 501,188 502,189 503,190 504,191 505,192 506,193 507,194 508,195 509,196 510,197 511,198 512,198 513,197 514,196 515,195 516,194 517,193 518,193 519,193 520,193 521,193 522,193 523,192 524,191 525,191 526,190 527,191 528,192 529,192 530,192 531,193 532,193 533,193 534,194 535,194 536,194 537,194 538,193 539,193 540,193 541,194 542,194 543,194 544,195 545,195 546,195 547,194 548,193 549,193 550,193 551,192 552,192 553,193 554,193 555,193 555,215 554,216 553,216 552,217 551,216 550,216 549,216 548,216 547,216 546,215 545,215 544,215 543,215 542,215 541,215 540,215 539,215 538,216 537,216 536,216 535,216 534,216 533,216 532,216 531,215 530,215 529,215 528,215 527,215 526,215 525,215 524,214 523,214 522,214 521,214 520,214 519,214 518,214"
image_path = "input.jpg"
output_path = "output.jpg"
image = cv2.imread(image_path)
points = [tuple(map(int, pt.split(','))) for pt in points_str.split()]
pts = np.array(points)
# Overlay the scribble (path) onto the image using OpenCV
image = cv2.polylines(image, [pts], isClosed=False, color=(0, 0, 255), thickness=2)
cv2.imwrite(output_path, image)
@chaitanya-lakkundi
Copy link
Author

Input and output images attached.
input
output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment