Skip to main content
added 578 characters in body
Source Link
Jack
  • 35
  • 1
  • 7

UPDATE : New error :

Traceback (most recent call last):
  File "F:\TIPE ENTROPIE\Programmation\essai.py", line 80, in <module>
    extract_iris(img)
  File "F:\TIPE ENTROPIE\Programmation\essai.py", line 49, in extract_iris
    cord    = get_circle(cimg, 35, 0, 50, 40)
  File "F:\TIPE ENTROPIE\Programmation\essai.py", line 8, in get_circle
    img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.error: C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:11111: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor

UPDATE : New error :

Traceback (most recent call last):
  File "F:\TIPE ENTROPIE\Programmation\essai.py", line 80, in <module>
    extract_iris(img)
  File "F:\TIPE ENTROPIE\Programmation\essai.py", line 49, in extract_iris
    cord    = get_circle(cimg, 35, 0, 50, 40)
  File "F:\TIPE ENTROPIE\Programmation\essai.py", line 8, in get_circle
    img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.error: C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:11111: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor

I am currently using Hough CirclesHoughCircles on computer visioncomputer-vision but I can't manage to make it work. How can this error be solved ?

Error : 'Traceback (most recent call last):
File "F:\TIPE ENTROPIE\Programmation\Iris-Recognition-master\Iris Code\norm.py", line 82, in
extract_iris(img)
File "F:\TIPE ENTROPIE\Programmation\Iris-Recognition-master\Iris Code\norm.py", line 53, in extract_iris
cord = get_circle(img, 35, 0, 50, 40)
File "F:\TIPE ENTROPIE\Programmation\Iris-Recognition-master\Iris Code\norm.py", line 14, in get_circle
circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT,1,20, param1=p1,param2=p2,minRadius=minR,maxRadius=maxR)
cv2.error: C:\projects\opencv-python\opencv\modules\imgproc \src\hough.cpp:1494: error: (-215) !_image.empty() && _image.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) && (_image.isMat() || _image.isUMat()) in function cv::HoughCircles`

Error : 
'Traceback (most recent call last):  
  File "F:\TIPE ENTROPIE\Programmation\Iris-Recognition-master\Iris   Code\norm.py", line 82, in <module>  
    extract_iris(img)  
  File "F:\TIPE ENTROPIE\Programmation\Iris-Recognition-master\Iris   Code\norm.py", line 53, in extract_iris  
    cord     = get_circle(img, 35, 0, 50, 40)  
  File "F:\TIPE ENTROPIE\Programmation\Iris-Recognition-master\Iris   Code\norm.py", line 14, in get_circle  
    circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT,1,20,   param1=p1,param2=p2,minRadius=minR,maxRadius=maxR)  
cv2.error: C:\projects\opencv-python\opencv\modules\imgproc  \src\hough.cpp:1494: error: (-215) !_image.empty() && _image.type() == (((0)   & ((1 << 3) - 1)) + (((1)-1) << 3)) && (_image.isMat() || _image.isUMat()) in   function cv::HoughCircles`  

Here is my code :

`

I am currently using Hough Circles on computer vision but I can't manage to make it work. How can this error be solved ?

Error : 'Traceback (most recent call last):
File "F:\TIPE ENTROPIE\Programmation\Iris-Recognition-master\Iris Code\norm.py", line 82, in
extract_iris(img)
File "F:\TIPE ENTROPIE\Programmation\Iris-Recognition-master\Iris Code\norm.py", line 53, in extract_iris
cord = get_circle(img, 35, 0, 50, 40)
File "F:\TIPE ENTROPIE\Programmation\Iris-Recognition-master\Iris Code\norm.py", line 14, in get_circle
circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT,1,20, param1=p1,param2=p2,minRadius=minR,maxRadius=maxR)
cv2.error: C:\projects\opencv-python\opencv\modules\imgproc \src\hough.cpp:1494: error: (-215) !_image.empty() && _image.type() == (((0) & ((1 << 3) - 1)) + (((1)-1) << 3)) && (_image.isMat() || _image.isUMat()) in function cv::HoughCircles`

Here is my code :

`

I am currently using HoughCircles on computer-vision but I can't manage to make it work. How can this error be solved ?

Error : 
'Traceback (most recent call last):  
  File "F:\TIPE ENTROPIE\Programmation\Iris-Recognition-master\Iris   Code\norm.py", line 82, in <module>  
    extract_iris(img)  
  File "F:\TIPE ENTROPIE\Programmation\Iris-Recognition-master\Iris   Code\norm.py", line 53, in extract_iris  
    cord     = get_circle(img, 35, 0, 50, 40)  
  File "F:\TIPE ENTROPIE\Programmation\Iris-Recognition-master\Iris   Code\norm.py", line 14, in get_circle  
    circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT,1,20,   param1=p1,param2=p2,minRadius=minR,maxRadius=maxR)  
cv2.error: C:\projects\opencv-python\opencv\modules\imgproc  \src\hough.cpp:1494: error: (-215) !_image.empty() && _image.type() == (((0)   & ((1 << 3) - 1)) + (((1)-1) << 3)) && (_image.isMat() || _image.isUMat()) in   function cv::HoughCircles`  

Here is my code :

added 1 character in body
Source Link
Jack
  • 35
  • 1
  • 7
import cv2 
import numpy as np

## Definitions

def get_circle(img, minR, maxR, p1, p2):
    
    circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT,1,20, param1=p1,param2=p2,minRadius=minR,maxRadius=maxR)
    circles = np.uint16(np.around(circles))

    #return the first circle
    return circles[0][0]

def print_img(img,x,y,w,h):
    if w!=0 and h!=0:
        cv2.imshow('detected circles',img[x:x+w,y:y+h])
        cv2.imwrite('app-1/1.jpg',img[x:x+w,y:y+h])
    else:
        cv2.imshow('detected circles',img)
        cv2.imwrite('app-1/1.jpg',img)
    cv2.waitKey(0)

    cv2.destroyAllWindows() 

def reject_out(img, xc, yc, r):
    row = len(img)
    col = len(img[0])

    for x in range(0,row):
        for y in range(0, col):
            res = (x-xc)*(x-xc) + (y-yc)*(y-yc)
            if res > r*r :
                img[x][y] = 0

def reject_in(img, xc, yc, r):
    xs = xc-r
    ys = yc-r

    for x in range(xs,xs+2*r):
        for y in range(ys, ys+2*r):
            res = (x-xc)*(x-xc) + (y-yc)*(y-yc)
            if res < r*r :
                img[x][y] = 0

def extract_iris(img):
    cimg    = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
    cord    = get_circle(imgcimg, 35, 0, 50, 40)
    # draw the outer circle
    cv2.circle(cimg,(cord[0],cord[1]),cord[2],(0,255,0),2)
    # draw the center of the circle
    cv2.circle(cimg,(cord[0],cord[1]),2,(0,0,255),3)
    

    h = 2*cord[2]
    w = 2*cord[2]
    x = cord[1]-cord[2]
    y = cord[0]-cord[2]
    nimg = img[x:x+w,y:y+h]
    reject_out(nimg, h/2, w/2, h/2)
    print_img(cimg,0,0,0,0)

    cord    = get_circle(nimg, 0, cord[2]-1, 50, 30)
    print (nimg[0:w][cord[0]])
    # draw the outer circle
    cv2.circle(nimg,(cord[0],cord[1]),cord[2],(0,255,0),2)
    # draw the center of the circle
    cv2.circle(nimg,(cord[0],cord[1]),2,(0,0,255),3)
    reject_in(nimg, cord[1], cord[0], cord[2])
    print_img(nimg,0,0,0,0)
    print (nimg[0:w][cord[0]])

    
    
img = cv2.imread('test6.jpg',0)
img = cv2.medianBlur(img,5)
extract_iris(img)
`
import cv2 
import numpy as np

## Definitions

def get_circle(img, minR, maxR, p1, p2):
    
    circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT,1,20, param1=p1,param2=p2,minRadius=minR,maxRadius=maxR)
    circles = np.uint16(np.around(circles))

    #return the first circle
    return circles[0][0]

def print_img(img,x,y,w,h):
    if w!=0 and h!=0:
        cv2.imshow('detected circles',img[x:x+w,y:y+h])
        cv2.imwrite('app-1/1.jpg',img[x:x+w,y:y+h])
    else:
        cv2.imshow('detected circles',img)
        cv2.imwrite('app-1/1.jpg',img)
    cv2.waitKey(0)

    cv2.destroyAllWindows() 

def reject_out(img, xc, yc, r):
    row = len(img)
    col = len(img[0])

    for x in range(0,row):
        for y in range(0, col):
            res = (x-xc)*(x-xc) + (y-yc)*(y-yc)
            if res > r*r :
                img[x][y] = 0

def reject_in(img, xc, yc, r):
    xs = xc-r
    ys = yc-r

    for x in range(xs,xs+2*r):
        for y in range(ys, ys+2*r):
            res = (x-xc)*(x-xc) + (y-yc)*(y-yc)
            if res < r*r :
                img[x][y] = 0

def extract_iris(img):
    cimg    = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
    cord    = get_circle(img, 35, 0, 50, 40)
    # draw the outer circle
    cv2.circle(cimg,(cord[0],cord[1]),cord[2],(0,255,0),2)
    # draw the center of the circle
    cv2.circle(cimg,(cord[0],cord[1]),2,(0,0,255),3)
    

    h = 2*cord[2]
    w = 2*cord[2]
    x = cord[1]-cord[2]
    y = cord[0]-cord[2]
    nimg = img[x:x+w,y:y+h]
    reject_out(nimg, h/2, w/2, h/2)
    print_img(cimg,0,0,0,0)

    cord    = get_circle(nimg, 0, cord[2]-1, 50, 30)
    print (nimg[0:w][cord[0]])
    # draw the outer circle
    cv2.circle(nimg,(cord[0],cord[1]),cord[2],(0,255,0),2)
    # draw the center of the circle
    cv2.circle(nimg,(cord[0],cord[1]),2,(0,0,255),3)
    reject_in(nimg, cord[1], cord[0], cord[2])
    print_img(nimg,0,0,0,0)
    print (nimg[0:w][cord[0]])

    
    
img = cv2.imread('test6.jpg',0)
img = cv2.medianBlur(img,5)
extract_iris(img)
`
import cv2 
import numpy as np

## Definitions

def get_circle(img, minR, maxR, p1, p2):
    
    circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT,1,20, param1=p1,param2=p2,minRadius=minR,maxRadius=maxR)
    circles = np.uint16(np.around(circles))

    #return the first circle
    return circles[0][0]

def print_img(img,x,y,w,h):
    if w!=0 and h!=0:
        cv2.imshow('detected circles',img[x:x+w,y:y+h])
        cv2.imwrite('app-1/1.jpg',img[x:x+w,y:y+h])
    else:
        cv2.imshow('detected circles',img)
        cv2.imwrite('app-1/1.jpg',img)
    cv2.waitKey(0)

    cv2.destroyAllWindows() 

def reject_out(img, xc, yc, r):
    row = len(img)
    col = len(img[0])

    for x in range(0,row):
        for y in range(0, col):
            res = (x-xc)*(x-xc) + (y-yc)*(y-yc)
            if res > r*r :
                img[x][y] = 0

def reject_in(img, xc, yc, r):
    xs = xc-r
    ys = yc-r

    for x in range(xs,xs+2*r):
        for y in range(ys, ys+2*r):
            res = (x-xc)*(x-xc) + (y-yc)*(y-yc)
            if res < r*r :
                img[x][y] = 0

def extract_iris(img):
    cimg    = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
    cord    = get_circle(cimg, 35, 0, 50, 40)
    # draw the outer circle
    cv2.circle(cimg,(cord[0],cord[1]),cord[2],(0,255,0),2)
    # draw the center of the circle
    cv2.circle(cimg,(cord[0],cord[1]),2,(0,0,255),3)
    

    h = 2*cord[2]
    w = 2*cord[2]
    x = cord[1]-cord[2]
    y = cord[0]-cord[2]
    nimg = img[x:x+w,y:y+h]
    reject_out(nimg, h/2, w/2, h/2)
    print_img(cimg,0,0,0,0)

    cord    = get_circle(nimg, 0, cord[2]-1, 50, 30)
    print (nimg[0:w][cord[0]])
    # draw the outer circle
    cv2.circle(nimg,(cord[0],cord[1]),cord[2],(0,255,0),2)
    # draw the center of the circle
    cv2.circle(nimg,(cord[0],cord[1]),2,(0,0,255),3)
    reject_in(nimg, cord[1], cord[0], cord[2])
    print_img(nimg,0,0,0,0)
    print (nimg[0:w][cord[0]])

    
    
img = cv2.imread('test6.jpg',0)
img = cv2.medianBlur(img,5)
extract_iris(img)
`
added 2922 characters in body
Source Link
Jack
  • 35
  • 1
  • 7
Loading
deleted 6 characters in body
Source Link
Jack
  • 35
  • 1
  • 7
Loading
Source Link
Jack
  • 35
  • 1
  • 7
Loading