OpenCV C++/Obj-C: Detecting a sheet of paper / Square Detection

I successfully implemented the OpenCV square-detection example in my test application, but now need to filter the output, because it’s quite messy – or is my code wrong? I’m interested in the four corner points of the paper for skew reduction (like that) and further processing … Input & Output: Original image: click Code: double angle( … Read more

ImportError: numpy.core.multiarray failed to import

I’m trying to run this program import cv2 import time cv.NamedWindow(“camera”, 1) capture = cv.CaptureFromCAM(0) while True: img = cv.QueryFrame(capture) cv.ShowImage(“camera”, img) if cv.WaitKey(10) == 27: break cv.DestroyAllWindows() But I’m having a problem with numpy, I’m using pyschopy along with opencv. The problem I keep getting is this error report: RuntimeError: module compiled against API … Read more

How to resize an image with OpenCV2.0 and Python2.6

I want to use OpenCV2.0 and Python2.6 to show resized images. I used and adopted this example but unfortunately, this code is for OpenCV2.1 and does not seem to be working on 2.0. Here my code: import os, glob import cv ulpath = “exampleshq/” for infile in glob.glob( os.path.join(ulpath, “*.jpg”) ): im = cv.LoadImage(infile) thumbnail … Read more

Python – Extracting and Saving Video Frames

So I’ve followed this tutorial but it doesn’t seem to do anything. Simply nothing. It waits a few seconds and closes the program. What is wrong with this code? import cv2 vidcap = cv2.VideoCapture(‘Compton.mp4’) success,image = vidcap.read() count = 0 success = True while success: success,image = vidcap.read() cv2.imwrite(“frame%d.jpg” % count, image) # save frame … Read more

How do I install Python OpenCV through Conda?

I’m trying to install OpenCV for Python through Anaconda, but I can’t seem to figure this out. I tried conda install opencv conda install cv2 I also tried searching conda search cv No cigar. I ran across this which lists opencv as an included package: http://docs.continuum.io/anaconda/pkgs.html After running conda info I noticed my version is … Read more

How to crop an image in OpenCV using Python

How can I crop images, like I’ve done before in PIL, using OpenCV. Working example on PIL im = Image.open(‘0.png’).convert(‘L’) im = im.crop((1, 1, 98, 33)) im.save(‘_0.png’) But how I can do it on OpenCV? This is what I tried: im = cv.imread(‘0.png’, cv.CV_LOAD_IMAGE_GRAYSCALE) (thresh, im_bw) = cv.threshold(im, 128, 255, cv.THRESH_OTSU) im = cv.getRectSubPix(im_bw, (98, … Read more

Cannot find module cv2 when using OpenCV

I have installed OpenCV on the Occidentalis operating system (a variant of Raspbian) on a Raspberry Pi, using jayrambhia’s script found here. It installed version 2.4.5. When I try import cv2 in a Python program, I get the following message: pi@raspberrypi~$ python cam.py Traceback (most recent call last) File “cam.py”, line 1, in <module> import … Read more