Ask Your Question

Subhajit Biswas's profile - activity

2019-11-18 15:04:10 -0600 received badge  Popular Question (source)
2016-07-23 08:52:54 -0600 asked a question Getting openCV error: Assertion Failed

I'm using opencv 3.1 in RaspberryPi 3. I,m trying to run the following Hough Circle detection algorithm

! /usr/bin/python

import numpy as np import cv2 from cv2 import cv

VInstance = cv2.VideoCapture(0) key = True

""" params = dict(dp, minDist, circles, param1, param2, minRadius, maxRadius) """ def draw_circles(circles, output):

if circles is not None:

    for i in circles[0,:]:
        #draw the outer circle
        cv2.circle(output,(i[0],i[1]),i[2],(0,255,0),2)
        #draw the centre of the circle
        cv2.circle(output,(i[0],i[1]),2,(0,0,255),3)
        print("The number of circles if %d" %(circles[0].shape[0]))      
elif circles is None:
    print ("The number of circles is 0")

if __name__ == '__main__':

while key:
    ret,img = VInstance.read()
    ## Smooth image to reduce the input noise

    imgGray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    imgSmooth = cv2.GaussianBlur(imgGray,(5,5),3)

    ## Compute Hough Circles
    circles = cv2.HoughCircles(imgSmooth,cv2.cv.CV_HOUGH_GRADIENT,1,100,
                               param1=80,
                               param2=50,
                               minRadius=50,
                               maxRadius=100)
    draw_circles(circles,img)

    ## Display the circles
    cv2.imshow('detected circles',imgGray)
    cv2.imshow("result",img)
    k = cv2.waitKey(1)
    if k == 27:
        cv2.destroyAllWindows()
        break

But I'm getting Assertion Failed error, details are below. OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /home/pi/opencv-3.1.0/modules/imgproc/src/color.cpp, line 8000 Traceback (most recent call last): File "HoughCircles.py", line 70, in <module> imgGray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) cv2.error: /home/pi/opencv-3.1.0/modules/imgproc/src/color.cpp:8000: error: (-215) scn == 3 || scn == 4 in function cvtColor

Can anyone please check and help!

2016-04-19 01:36:02 -0600 commented answer ImportError: cannot import name cv

Thanks for your reply.

I tried that and now I'm getting the following errors:

libv4l2: error setting pixformat: Device or resource busy VIDEOIO ERROR: libv4l unable to ioctl S_FMT libv4l2: error setting pixformat: Device or resource busy libv4l1: error setting pixformat: Device or resource busy VIDEOIO ERROR: libv4l unable to ioctl VIDIOCSPICT

OpenCV Error: Assertion failed (scn == 3 || scn == 4) in ipp_cvtColor, file /home/subhajit/opencv-3.1.0/modules/imgproc/src/color.cpp, line 7456 Traceback (most recent call last): File "HoughCircles.py", line 76, in <module> imgGray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) cv2.error: /home/subhajit/opencv-3.1.0/modules/imgproc/src/color.cpp:7456: error: (-215) scn == 3 || scn == 4 in function ipp_cvtColor

2016-04-19 01:30:51 -0600 commented question Authentication error with Pi3 and OpenCV-3.0.0

OK, thanks for your reply

2016-04-19 01:28:09 -0600 asked a question ImportError: cannot import name cv

I'm using ubuntu 15.10 and opencv-3.1.0. When I tried to run a python code I'm getting the following error

ImportError: cannot import name cv

The same code was running fine with another ubuntu machine and opencv

Don't know whats the problem Someone kindly help

2016-04-19 01:22:17 -0600 asked a question Authentication error with Pi3 and OpenCV-3.0.0

Hi,

I'm SSH ing my Pi3 over wifi with Ubuntu 15.10. I was trying to run one of the sample python codes in OpenCV-3.0.0. I'm getting the following error:

X11 connection rejected because of wrong authentication. : cannot connect to X server localhost:10.0

Then I did VNC and try to run in from Raspbian, there I'm getting following error:

Client is not authorized to connect to server: cannot connect to X server :1.0

I did tried to use the instructions in the following link http://unix.stackexchange.com/questions ... entication

But that doesn't helped, when I did sudo su and went to the root, it is not showing any directory there.

Don't know how to solve it. Kindly, someone help

2016-04-10 10:47:19 -0600 asked a question I'm new to openCV, trying to use it differentiate objects based on its clolor. Checked some the available codes but getting error. Uisng Raspberry Pi camera for taking image.

I'm using Raspberry Pi and OpenCV-3.0.0. trying to make a project which can able to sort objects based on its color, for eg; it select red objects and rejects green or yellow objects. I'm done with the mechanism, but when I tried the existing codes in Internet for sorting, I am getting error.

Can someone help me with the code. Thanks