Filling holes inside a binary object

There are two methods to do this: 1) Contour Filling: First, invert the image, find contours in the image, fill it with black and invert back. des = cv2.bitwise_not(gray) contour,hier = cv2.findContours(des,cv2.RETR_CCOMP,cv2.CHAIN_APPROX_SIMPLE) for cnt in contour: cv2.drawContours(des,[cnt],0,255,-1) gray = cv2.bitwise_not(des) Resulting image: 2) Image Opening: kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(3,3)) res = cv2.morphologyEx(gray,cv2.MORPH_OPEN,kernel) The resulting image is … Read more

UnsatisfiedLinkError: no opencv_java249 in java.library.path

Look into your OpenCV directory; For an example this; (installed using brew install opencv3 –with-java –with-python3) /usr/local/Cellar/opencv3/XXX/share/OpenCV/java You will see; libopencv_javaXXX.so opencv-XXX.jar Now that you already have OpenCV’s native library for Java (libopencv_javaXXX.so) compiled with you, the only thing left is, mac’s dynamic library. Link libopencv_javaXXX.so to libopencv_javaXXX.dylib; ln -s libopencv_javaXXX.so libopencv_javaXXX.dylib Now add /usr/local/Cellar/opencv3/XXX/share/OpenCV/java … Read more