I am trying to do the Delaunay Triangulation using Python 3.5.2 and OpenCV 3.1. I am trying to use the function cv2.cv2.Subdiv2D(rect)
but I am not able to add a point to the Subdiv object. What am I doing wrong?
import numpy as np
import cv2
point = np.array([[1, 1]])
rect = (0, 0, 10, 10)
# Create an instance of Subdiv2D
subdiv = cv2.Subdiv2D(rect[0])
subdiv.insert(point)
It is throwing this message:
OpenCV Error: Assertion failed (channels() == CV_MAT_CN(dtype)) in copyTo, file /Users/jenkins/miniconda/1/x64/conda-bld/work/opencv-3.1.0/modules/core/src/copy.cpp, line 257
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/jenkins/miniconda/1/x64/conda-bld/work/opencv-3.1.0/modules/core/src/copy.cpp:257: error: (-215) channels() == CV_MAT_CN(dtype) in function copyTo
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
I may be wrong but shouldn't it be: point = np.array([[1, 1]])
? The way you are doing you are declaring an array with values 1 and 1, not an array of points.
Edit:
Try using points as tuples:
points_list = []
points_list.append((1,1))
Source: http://www.learnopencv.com/delaunay-triangulation-and-voronoi-diagram-using-opencv-c-python/