Created
October 5, 2017 12:50
-
-
Save stefanocoding/eb4e816cb0f41b67b5f47bd19445de11 to your computer and use it in GitHub Desktop.
Plot curve using OpenCV instead of Matplotlib's plot().
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you have something like this | |
matplotlib.pyplot.plot(x_values, y_values, color='yellow') | |
# You can do the same on OpenCV like this | |
curve = numpy.column_stack((x_values.astype(numpy.int32), y_values.astype(numpy.int32))) | |
cv2.polylines(image, [curve], False, (0,255,255)) | |
# And if you need to plot more curves just add them as an element to the array of polygonal curves | |
curve1 = numpy.column_stack((x1.astype(numpy.int32), y1.astype(numpy.int32))) | |
curve2 = numpy.column_stack((x2.astype(numpy.int32), y2.astype(numpy.int32))) | |
cv2.polylines(image, [curve1, curve2], False, (0,255,255)) | |
# More information http://docs.opencv.org/2.4/modules/core/doc/drawing_functions.html#polylines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment