Ask Your Question

I.Zaytsev's profile - activity

2020-10-26 12:14:56 -0600 received badge  Notable Question (source)
2018-09-19 06:53:51 -0600 received badge  Popular Question (source)
2017-09-11 10:37:50 -0600 received badge  Student (source)
2013-10-23 17:08:58 -0600 received badge  Taxonomist
2013-07-16 22:15:32 -0600 asked a question remove barrel distortion

Hello! I have several of the following images:

image1

image2

image3

I have a task to recognize the text on the labels. I will recognize the text using the FineReader Engine (special SDK for recognize images). However, I need to do preprocessing of images for better recognition. What do I need to do to remove barrel distortion and other distortions?

For example, FineReader bad recognizes the "BordeauX" word in the first image(image1), it instead of the "BordeauX" word sees "ordeauX", may be because there is a flare? How can this be fixed?

Have any idea how to do the preprocessing of the images?

2013-05-28 02:03:29 -0600 asked a question how to draw the lines in the source image

Hi, all!
I want to detect largest rectangle. This source image.
I write this code:

def rectangle_detection():
    src = cv2.imread("rectangles.jpg")
    if src == None:
        print "Do not open image!"
        return -1

    gray = cv2.cvtColor(src, cv2.cv.CV_BGR2GRAY)
    blur = cv2.blur(src, (3,3))
    canny = cv2.Canny(gray, 100, 100, 5)
    lines = cv2.HoughLinesP(canny, 1, cv2.cv.CV_PI/180, 70, 30, 10)

image after HougLinesP()
how to draw the lines int the sorce image? and what should I do next?
Thanks!

2013-05-28 00:50:01 -0600 commented answer numpy.array setting an array element with a sequence

ok! thanks :)

2013-05-27 10:00:16 -0600 commented answer How to detect largest rectengle in image and draw the lines??

OpenCV are similar for different programming languages
Compare them and you find solution...

2013-05-27 05:27:03 -0600 answered a question How to detect largest rectengle in image and draw the lines??

this code for draw line around pupil(python):

   gray = cv2.cvtColor(~src, cv2.cv.CV_BGR2GRAY)
    cv2.threshold(gray, 220, 255, cv2.THRESH_BINARY, gray)

    contours, hierarchy = cv2.findContours(gray.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)

    cv2.drawContours(gray, contours, -1, cv2.cv.RGB(255,255,255), -1)

    i = 0
    while i < len(contours):
        area = cv2.contourArea(contours[i])
        rect = cv2.boundingRect(contours[i])
        radius = rect[2] / 2 #rect[2] - width
        i = i + 1
        if area >= 30:
            if abs(1 - (rect[2] / rect[3])) <= 0.2: #rect[3] - height
                if abs(1 - (area / (cv2.cv.CV_PI * pow(radius, 2))) < 0.2):
                    cv2.circle(src, (rect[0] + radius, rect[1] + radius), radius, cv2.cv.RGB(255, 0, 0), 2)
                    cv2.imwrite(str("") + str("1") + ".jpg", src)
                    break

I think that you will have a similar situation

2013-05-27 03:31:24 -0600 commented answer numpy.array setting an array element with a sequence

thanks! it's work:
contours, hierarchy = cv2.findContours(gray.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
cv2.drawContours(gray, contours, -1, cv2.cv.RGB(255,255,255), -1)

2013-05-27 03:30:36 -0600 received badge  Scholar (source)
2013-05-27 00:39:38 -0600 received badge  Editor (source)
2013-05-26 22:52:37 -0600 asked a question numpy.array setting an array element with a sequence

HellO! I am russian student and I began to study OpenCV :) I write this code:

import cv2
import numpy

def eye_detection():
    src = cv2.imread("E:\\Ilya\\PythonProjects\\eye.jpg")
    if src == None:
        print 'Do not open image!'
        return -1

    gray = cv2.cvtColor(~src, cv2.cv.CV_BGR2GRAY)
    cv2.threshold(gray, 220, 255, cv2.THRESH_BINARY, gray)

    contours = cv2.findContours(gray.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
    #cv2.imwrite(str("E:\\Ilya\\PythonProjects\\") + str("1") + ".jpg", gray)
    #print(contours)
    numpy.array(contours, dtype=numpy.float)
    cv2.drawContours(gray, cv2.cv.Scalar(contours), -1, cv2.cv.RGB(255,255,255), -1)
if __name__ == "__main__":
    eye_detection()

If I compile this script:

line 16, in eye_detection
    numpy.array(contours, dtype=numpy.float)
ValueError: setting an array element with a sequence.

contours contains(print(contours)):

([array([[[344, 254]]]), array([[[194, 243]],

       [[194, 244]],

       [[195, 244]],

       [[196, 244]],

       [[197, 244]],

       [[198, 244]],

       [[199, 244]],

       [[200, 244]],

       [[201, 244]],

       [[202, 244]],

       [[203, 244]],

       [[204, 244]],

       [[205, 244]],

       [[204, 244]],

       [[203, 244]],

       [[202, 244]],

       [[201, 243]],

       [[200, 243]],

       [[199, 243]],

       [[198, 243]],

       [[197, 243]],

       [[196, 243]],

       [[195, 243]]]), array([[[217, 242]], etc.

how to solve this problem?

2013-05-24 01:53:00 -0600 received badge  Supporter (source)