Q:

Open CV libgtk2.0-dev and pkg-config error mac

Hi I am fairly new to OpenCV and I am trying to get OpenCV demo-code for blur detection working on my mac but I get an error every time I run the code.
Here is the code I try to run:
    # import the necessary packages
from imutils import paths
import argparse
import cv2

def variance_of_laplacian(image):
    # compute the Laplacian of the image and then return the focus
    # measure, which is simply the variance of the Laplacian
    return cv2.Laplacian(image, cv2.CV_64F).var()

# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--images", required=True,
                help="path to input directory of images")
ap.add_argument("-t", "--threshold", type=float, default=100.0,
                help="focus measures that fall below this value will be considered 'blurry'")
args = vars(ap.parse_args())
# loop over the input images
for imagePath in paths.list_images(args["images"]):
    # load the image, convert it to grayscale, and compute the
    # focus measure of the image using the Variance of Laplacian
    # method
    image = cv2.imread(imagePath)
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    fm = variance_of_laplacian(gray)
    text = "Not Blurry"

    # if the focus measure is less than the supplied threshold,
    # then the image should be considered "blurry"
    if fm < args["threshold"]:
        text = "Blurry"

    # show the image
    cv2.putText(image, "{}: {:.2f}".format(text, fm), (10, 30),
                cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 0, 255), 3)
    cv2.imshow("Image", image)
    key = cv2.waitKey(0)

I run the code by executing:
python detect_blur.py --images images

This is my terminal output:
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp, line 583
Traceback (most recent call last):
  File "detect_blur.py", line 37, in <module>
    cv2.imshow("Image", image)
cv2.error: /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp:583: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage

I have already installed GTK+ and pkg-config but I still get the same error. I am not sure what to do next. I am fairly confident the problem is not with the code but with the installation
This is the tutorial I followed to install OpenCV
http://www.pyimagesearch.com/2016/12/19/install-opencv-3-on-macos-with-homebrew-the-easy-way/

A:

You might be using opencv-python , which doesn't support many features. You have to uninstall opencv-python and then reinstall or rebuild OpenCV.
pip uninstall opencv-python

On mac OS, you can reinstall OpenCV with
brew uninstall opencv3
brew install opencv3 --with-ffmpeg -v

Make sure you are using correct Python, you might have different versions of Python installed with either brew, pyenv, or anaconda. Check which python you are using by executing this:
which python

where /usr/local/bin/python is from brew, and you'll know the others from the keyword shown in path.

