How to use `cv2.findContours` in different OpenCV versions?

An alternative to work with 2.x 、3.x、4.x is: cnts, hiers = cv2.findContours(…)[-2:] Notice: cv2.findContours has changed since OpenCV 3.x, but in OpenCV 4.0 it changes back!!! In OpenCV 3.4: findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> image, contours, hierarchy In OpenCV 4.0: findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> contours, hierarchy

Plotting contours on an irregular grid

Here are some different possibilites using base R graphics and ggplot. Both simple contours plots, and plots on top of maps are generated. Interpolation library(akima) fld <- with(df, interp(x = Lon, y = Lat, z = Rain)) base R plot using filled.contour filled.contour(x = fld$x, y = fld$y, z = fld$z, color.palette = colorRampPalette(c(“white”, “blue”)), … Read more

Make contour of scatter

You can use tricontourf as suggested in case b. of this other answer: import matplotlib.tri as tri import matplotlib.pyplot as plt plt.tricontour(x, y, z, 15, linewidths=0.5, colors=”k”) plt.tricontourf(x, y, z, 15) Old reply: Use the following function to convert to the format required by contourf: from numpy import linspace, meshgrid from matplotlib.mlab import griddata def … Read more