1

While running code I am getting "init done opengl support available" as output message but I am not getting output images i.e. erosion and dilation. How should I get it?

import cv2
import numpy as np
img = cv2.imread('threshold.png',0)
kernel = np.ones((5,5),np.uint8)
erosion = cv2.erode(img,kernel,iterations = 1)
dilation = cv2.dilate(img,kernel,iterations = 1)
cv2.getStructuringElement(cv2.MORPH_RECT,(5,5))
cv2.imshow('erosion',erosion)    
cv2.imshow('dilation',dilation)    
print (erosion)
print (dilation)
sKhan
  • 9,694
  • 16
  • 55
  • 53

1 Answers1

1

Asuming you are on linux and using OpenCV 3.X (mine was 3.2), here is how I solved it:

1 Uninstall your current OpenCV version (you have how to do it here)

2 Download OpenCV again:

git clone https://github.com/opencv/opencv.git

3 Use the following commands:

mkdir release

cd release

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_QT=OFF -D WITH_TBB=OFF ..

make

sudo make install

It worked for me working under Ubuntu 14.04 and Python 2.7. You can find more information at the official webpage

Community
  • 1
  • 1
CodeSniffer
  • 83
  • 1
  • 10