Ask Your Question

begueradj's profile - activity

2019-04-30 14:50:55 -0500 received badge  Popular Question (source)
2019-03-08 02:35:12 -0500 received badge  Notable Question (source)
2018-08-07 09:10:40 -0500 received badge  Popular Question (source)
2018-04-11 16:05:16 -0500 received badge  Famous Question (source)
2018-03-16 00:17:36 -0500 received badge  Notable Question (source)
2018-01-24 07:58:03 -0500 received badge  Notable Question (source)
2017-10-12 05:06:34 -0500 received badge  Popular Question (source)
2017-05-01 17:47:07 -0500 received badge  Popular Question (source)
2017-02-25 11:43:43 -0500 received badge  Famous Question (source)
2017-01-31 08:21:05 -0500 received badge  Notable Question (source)
2016-08-25 13:51:42 -0500 received badge  Notable Question (source)
2016-07-01 00:57:27 -0500 received badge  Popular Question (source)
2016-06-14 07:18:19 -0500 received badge  Popular Question (source)
2016-03-26 19:23:41 -0500 marked best answer Unable to detect black pixels ?

I am reading a picture to color in red all its black pixels (the background only is black):

import numpy as np
import cv2

second=cv2.imread('second.png')

for i in range(second.shape[0]):
   for j in range(second.shape[1]):
       if second[i,j,0]!=0 and second[i,j,1]!=0 and second[i,j,2]!=0:
           second[i,j,0]=0
           second[i,j,1]=0
           second[i,j,2]=255
cv2.imwrite('result.png',second)

Here is the image second.png:

enter image description here

Here is the colored image result.png: enter image description here

Why not all the yellow rose is not colored in red ? Note when I print those pixels that are not colored (in red in result.png) in second.png I see they are not black. Why this ?

2016-03-22 10:17:04 -0500 marked best answer image segmentation

I wonder if there are algorithms used to segment images efficiently. The ones I tested by now can not segment hair correctly as on this image:

enter image description here

I just want to know if someone can give me some efficient algorithms to segment the hair on this image for example without cutting it and so on (correct segmentation)

Note that I tested famous algorithms such as watershed, grabcut, mean shift ... but no one of them segments this hair correctly.

Thank you very much in advance.

2016-02-28 12:21:47 -0500 commented question imread: readable max size

Thank you for the effort. I will need to dive deeper into the hints you gave me

2016-02-28 11:25:27 -0500 commented question imread: readable max size

Thank you, but I did before asking. It does not answer this question though.

2016-02-28 09:30:12 -0500 marked best answer inverting the background and object colors

I read in documentation that:

In OpenCV, finding contours is like finding white object from black background. So remember, object to be found should be white and background should be black.

In my case, all the images I am dealing with are colorful but their background is always white. Is there any solution in OpenCV to make the background of these images black and the objects white in order to apply cv2.findCountours() function ?

2016-02-28 09:20:10 -0500 asked a question imread: readable max size

What is the maximum image size that OpenCV can read when using:

img=cv2.imread('image.jpg')

P.S. Suppose I have enough RAM

2016-01-25 06:28:18 -0500 received badge  Popular Question (source)
2015-07-17 17:36:47 -0500 marked best answer draw with mouse continuously

I am trying to draw following the movements of the mouse. It works ok.

When I move the mouse slowly, what is drawn looks continuous, but when I speed a little bit the mouse movement, I get discontinuous drawings.

How can I draw with the mouse continusouly ?

import cv2
import numpy as np 

drawing=False # true if mouse is pressed
mode=True # if True, draw rectangle. Press 'm' to toggle to curve

# mouse callback function
def interactive_drawing(event,x,y,flags,param):
    global ix,iy,drawing, mode

    if event==cv2.EVENT_LBUTTONDOWN:
        drawing=True
        ix,iy=x,y

    elif event==cv2.EVENT_MOUSEMOVE:
        if drawing==True:
            if mode==True:
                cv2.circle(img,(x,y),1,(0,0,255),-1)
                print x,y
    elif event==cv2.EVENT_LBUTTONUP:
        drawing=False
        if mode==True:
            cv2.circle(img,(x,y),1,(0,0,255),-1)
            #print x,y
            #cv2.line(img,(x,y),(x,y),(0,0,255),10)
    return x,y




img = np.zeros((512,512,3), np.uint8)

cv2.namedWindow('begueradj')
cv2.setMouseCallback('begueradj',interactive_drawing)
while(1):
    cv2.imshow('begueradje',img)
    k=cv2.waitKey(1)&0xFF
    if k==27:
        break
cv2.destroyAllWindows()
2015-05-27 08:54:21 -0500 asked a question Haar detector features: where to find them ?

From here we can read:

Authors' detector had 6000+ features with 38 stages with 1, 10, 25, 25 and 50 features in first five stages. (Two features in the above image is actually obtained as the best two features from Adaboost). According to authors, on an average, 10 features out of 6000+ are evaluated per sub-window.

Question:

Where can I find the list of those features ?

or may be someone can list me some of them ? I'm curious to know what they are about.

Begueradj

2015-05-26 03:34:59 -0500 asked a question (-215) scaleFactor > 1 && image.depth() == CV_8U in function detectMultiScale

I run the code below taken from documentation:

 import numpy as np
 import cv2

 face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
 eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml')

 img = cv2.imread('sachin.jpg')
 gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)


 faces = face_cascade.detectMultiScale(gray, 1.3, 5)
 for (x,y,w,h) in faces:
   cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
   roi_gray = gray[y:y+h, x:x+w]
   roi_color = img[y:y+h, x:x+w]
   eyes = eye_cascade.detectMultiScale(roi_gray)
   for (ex,ey,ew,eh) in eyes:
     cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)

cv2.imshow('img',img)
cv2.waitKey(0)

cv2.destroyAllWindows()

But I got this error message:

Traceback (most recent call last):
  File "testa.py", line 10, in <module>
    faces=face_cascade.detectMultiScale(gray,1,3,5)
cv2.error: /home/nakkini/opencv/opencv-2.4.10/modules/objdetect/src/cascadedetect.cpp:1081: error: (-215) scaleFactor > 1 && image.depth() == CV_8U in function detectMultiScale

How can I resolve this problem ?

Thank you very much in advance.

2015-05-22 06:33:21 -0500 commented question OpenCV vs OpenBR

@thdrksdfthmn thank you very much for your concern. But I just wonder if OpenBR does not share most of its algorithms inherent to face stuff with OpenCV ?

2015-05-22 02:44:23 -0500 commented question OpenCV vs OpenBR

@thdrksdfthmn do you mean that OpenBR is faster and more efficient than OpenCV in different facial detection ?

2015-05-19 04:19:15 -0500 asked a question OpenCV vs OpenBR

Is openCV more performant than openBR when it comes to gender,age and face detections?

Begueradj

2015-05-18 02:56:11 -0500 asked a question Unable to stop the stream: Bad file descriptor

This is the first time I try to prone this aspect of OpenCV: camera and video capture. So logically, there is nothing to do in the start other than trying to run and unerstand the basic examples such as this one which is the first to be published on the OpenCV official documentation.

I just did a copy/past to test1.py file and run it to get this error message:

    Traceback (most recent call last)
       File "test1.py", line 10, in <module>
          gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    cv2.error: /home/Begueradj/opencv/opencv-2.4.10/modules/imgproc/src/color.cpp:3739: error: (-215) scn == 3 || scn == 4 in function cvtColor

    Unable to stop the stream: Bad file descriptor

May be someone could clarify to me why this happened and how to resolve it ?

Thank you very much in advance.

2015-04-25 05:27:33 -0500 marked best answer OpenCV: BGR to YUV conversion

Is there a way to convert an image from BGR to YUV color space ?

2015-04-20 01:35:11 -0500 commented question wrong image slicing

@StevenPuttemans yes, you were right. Thank you very much

2015-04-14 07:14:00 -0500 commented question wrong image slicing

@StevenPuttemans But why the original image is displaying without the aliasing problem then unlike the other 4 blocks ?

2015-04-14 03:33:26 -0500 asked a question wrong image slicing

I want to divide a picture into 4 blocks of the same size. Here is my code:

import numpy as np
import cv2
import cv
im=cv2.imread('homer.jpg')

print im.shape # (548, 500, 3)
im1=im[0:273,0:249]
im2=im[274:547,0:249]
im3=im[0:273,250:499]
im4=im[274:547,250:499]

cv2.namedWindow('im1',cv2.WINDOW_AUTOSIZE)
cv2.namedWindow('im2',cv2.WINDOW_AUTOSIZE)
cv2.namedWindow('im3',cv2.WINDOW_AUTOSIZE)
cv2.namedWindow('im4',cv2.WINDOW_AUTOSIZE)

a=np.hstack((im1,im3))
b=np.hstack((im2,im4))

r=np.vstack((a,b))
cv2.namedWindow('original',cv2.WINDOW_AUTOSIZE)
cv2.imshow('original',im)

cv2.imshow('im1',im1.copy())
cv2.imshow('im2',im2.copy())
cv2.imshow('im3',im3.copy())
cv2.imshow('im4',im4.copy())

cv2.imwrite('im1.jpg',im1)
cv2.imwrite('im2.jpg',im2)
cv2.imwrite('im3.jpg',im3)
cv2.imwrite('im4.jpg',im4)
cv2.imwrite('rebuilt_image.jpg',r)
cv2.waitKey(0)
cv2.destroyAllWindows()

Here are the results:

image description

My problem:

As you can see, there is aliasing effect that can clearly be seen in the 4 blocks unlike in the original image. This means the image slicing into 4 blocks is not enough good.

Someone could tell me what's wrong and how to correct ?

Thank you in advance

2015-04-14 02:45:09 -0500 commented question Display images larger than screen resolution: scrollbar window ?

I know there is no such scrollbar in OpenCV windows, I just wonder if there is a possibility to modify its source code and where to have this behavior. My application will be a mess if I want to display images in a given library and process them in an other one.

2015-04-13 09:04:25 -0500 commented question how to display 2 images in one ?

@Guanta thank you very much. Your idea works fine

2015-04-13 08:54:02 -0500 commented question how to display 2 images in one ?

@thdrksdfthmn I tried but the push_back does not exist in Python/numpy

2015-04-13 08:51:39 -0500 commented question how to display 2 images in one ?

@thdrksdfthmn thank you. In fact I have 4 blocks of the same image, all of them with the same size. Can I use push_back in this case too ?

2015-04-13 08:34:11 -0500 asked a question how to display 2 images in one ?

I read an image: im=cv2.imread('image.jpg')

I divide it into 2 pictures:

im1=im[0:199,0:99]
im2=im[200:399,0:99]

I display im1 and im2 separately. It is ok.

But now, I want to save im1 and im2 in combine and display combine which must display me the same image as im. How can I fulfill this ?

2015-04-13 08:13:30 -0500 commented question error: (-215) mat.isContinuous() in function copyFrom

@berak you mean the flag does not disable that menu context in your case ?