Ask Your Question

electron's profile - activity

2019-11-11 06:54:27 -0600 received badge  Notable Question (source)
2018-08-20 05:23:17 -0600 received badge  Popular Question (source)
2017-07-11 07:09:13 -0600 commented question Convert QPixmap to OpenCV image

Maybe you are right but the main problem here to convert to right opencv format

2017-07-11 06:51:33 -0600 asked a question Convert QPixmap to OpenCV image

I have PyQt5 QPixmap. I want to convert it to the same format as cv2.VideoCapture returns. How to achieve this? I use OpenCV in Python3.

2017-06-05 01:23:48 -0600 received badge  Critic (source)
2017-06-03 13:05:27 -0600 commented answer How to find distance between centers of two green boxes?

because cm count per pixel is different in these cases. distance in cm is the same, but in pixels it will change depends on your camera position. that's normal

2017-06-03 08:24:09 -0600 commented answer How to find distance between centers of two green boxes?

using your code. you wrote that you can find centers of boxes and seems that your code really can do this, just save coordinates cX, cY to appropiated variables

2017-06-03 07:09:34 -0600 answered a question How to find distance between centers of two green boxes?

For example, cX1 and cY1 are coordinates of center of first box, cX2 and cY2 are coordinates of center of second box. You can find the distance:

 distance = (((cX1 - cX2) ** 2) + ((cY1 - cY2) ** 2)) ** 0.5

If you know real sizes of boxes you can also compute distance in cm. But accuracy will be low.

2017-06-03 06:56:54 -0600 commented question How to find distance between centers of two green boxes?

you mean distance in pixels?

2017-05-31 10:12:47 -0600 answered a question Capturing webcam in python

This happens when for some reason cap.read() returns empty frame. just add a check:

while True:
    ret, frame = cap.read()
    if frame:
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        cv2.imshow('frame', gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
2017-05-23 11:14:07 -0600 commented question Python - Failure to import cv2: DLL load failed

btw, seems that you are trying to use in Python37 opencv installed for Python34. Check if you're using correct python versin and make sure that python is in PATH

2017-05-23 09:59:47 -0600 commented question Python - Failure to import cv2: DLL load failed

download wheel and install it using pip: pip install path_to_wheel

2017-05-22 12:20:34 -0600 commented question Python - Failure to import cv2: DLL load failed

Are you limited in using 3.2.0? If no I suggest to try prebuilt wheels: http://www.lfd.uci.edu/~gohlke/python...

2017-05-22 12:12:07 -0600 commented question opencv python merge different channel images into one

11 channels per single image? wow. seems that trivial cv2.merge() cannot do it. so probably slices?

2017-05-05 16:17:31 -0600 answered a question cv2.videoCapture(filename) assigning filename dynamically

1) Check if file exists. Try to use absolute path there, and use '/' instead of '\' if you are on windows

2) According to docs:

Sometimes, it is a headache to work with Video Capture mostly due to wrong installation of ffmpeg/gstreamer.

It can be an issue too

2017-05-05 16:05:12 -0600 commented question Store/print pixel-information after Object Detection is applied

depends on what object you want to detect

2017-05-04 14:03:26 -0600 received badge  Editor (source)
2017-05-04 13:57:34 -0600 answered a question Tuning parameters for cv2.houghcircle() method ?

Not sure that cv2.HoughCircles is the best option here. I recommend to try findContours also. Anyway question is about houghCircles, so example of code that detects all planets correctly:

import cv2
import numpy as np

planets = cv2.imread(path)
gray_img = cv2.cvtColor(planets, cv2.COLOR_BGR2GRAY)
gray_img = cv2.medianBlur(gray_img, 3)
circles = cv2.HoughCircles(gray_img, cv2.HOUGH_GRADIENT, 1, 10,
                    param1=350, param2=10, minRadius=2, maxRadius=13)
if circles is not None:  # circles found
    circles = np.uint16(np.around(circles))

    for i in circles[0,:]:
        cv2.circle(planets,(i[0],i[1]),i[2],(0,255,0),2)
        cv2.circle(planets,(i[0],i[1]),2,(0,0,255),3)

cv2.imshow("HoughCirlces", planets)
cv2.waitKey()
cv2.destroyAllWindows()

What I corrected in your code: set minimum distance between circles centers from 120 to 10, changed min and max radius for circle, changed param1 and param2. Also I adde check for case if no circles were found.

Docs that I used: link

Hope this helps!

2017-04-26 11:02:41 -0600 commented question OpenCV Error: Assertion failed ((scn == 3 || scn == 4) && (depth == CV_8U || depth == CV_32F)) in cvtColor

could you please provide code? are you sure that file that you try to open exists? try to show it using opencv and see what happens

2017-04-25 12:45:51 -0600 answered a question Detecting Blue Color in this image

I know it's too late, but this range works well for me:

lower_blue = np.array([100,150,0])
upper_blue = np.array([140,255,255])
2016-08-19 10:39:34 -0600 received badge  Enthusiast
2016-08-14 16:00:01 -0600 received badge  Scholar (source)
2016-08-14 15:59:23 -0600 received badge  Supporter (source)
2016-08-14 15:58:28 -0600 commented answer How to get Y, U, V from image

thanks! i will try it

2016-08-12 10:20:56 -0600 commented question How to get Y, U, V from image

btw i don't sure that convertion works properly because saved on disc out_image looks strange

2016-08-12 10:15:57 -0600 commented question How to get Y, U, V from image

I need YUV420, not YUV. so BGR2YUV_I420, not BGR2YUV

2016-08-12 09:46:06 -0600 answered a question Modulo cv2 has no attribute cv

cv2.cv is in opencv2, not in opencv3+. just use cv2.what_do_you_want() instead of cv2.cv.what_do_you_want()

2016-08-12 08:40:32 -0600 asked a question How to get Y, U, V from image

I use OpenCV 3.0 in Python3.4. I have BGR image converted to YUV420:

out_image = cv2.cvtColor(in_image, cv2.COLOR_BGR2YUV_I420)

How to get Y, U, V values from out_image?