Ask Your Question

LDG's profile - activity

2020-10-28 21:11:31 -0600 received badge  Notable Question (source)
2019-05-02 07:00:36 -0600 received badge  Popular Question (source)
2017-01-05 08:54:29 -0600 asked a question Extracting Contours from Image - Python

Hi guys, I am new with OpenCV3.2 and I am trying to extract the contours of this image: image description

I am executing the following Python code but I can't manage the to extract the contours of the image,

import numpy as np
import cv2

im = cv2.imread('start.jpg')
imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(imgray,127,255,0)
im, contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)

cv2.drawContours(im,contours,-1,(255,0,0),2)

for h,cnt in enumerate(contours):
    mask = np.zeros(imgray.shape,np.uint8)
    cv2.drawContours(mask,[cnt],0,255,-1)
    mean = cv2.mean(im,mask = mask)

    x, y, w, h = cv2.boundingRect(cnt)
    print('X: ', x, 'Y: ', y, 'W: ', w, 'H: ', h)
    cv2.rectangle(im, (x, y), (x + w, y + h), (255, 0, 0), 2)

cv2.imshow('win', im)
cv2.waitKey(0) 
cv2.destroyAllWindows()

when I try to print the 4 coordinates x, y, w, z it prints out many rows, I think because is detecting all the rectangles in the image.

I am stuck here for a couple of hours now and I really can't find a solution.

Can anyone help me?

Thank you in advance

2016-10-24 16:54:15 -0600 received badge  Student (source)
2016-10-21 08:10:29 -0600 received badge  Supporter (source)
2016-10-12 15:19:00 -0600 commented answer Errors on compiling OpenCV on MacOS Sierra

Yes, thanks anyway for your quick reply!

2016-10-12 15:18:33 -0600 received badge  Scholar (source)
2016-10-12 14:00:22 -0600 asked a question Errors on compiling OpenCV on MacOS Sierra

Good evening guys,

I am having an error when I execute the command

make -j4

on my terminal. The error is the following:

/Users/lucadigiammarino/opencv/modules/videoio/src/cap_qtkit.mm:46:9: fatal error: 'QTKit/QTKit.h' file not found
#import <QTKit/QTKit.h>
        ^
1 error generated.
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_qtkit.mm.o] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2

I have been following this tutorial http://www.pyimagesearch.com/2015/06/... in order to get OpenCV 3.1.0 with Python on my Mac.

This is what I execute in order to configure the build:

cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D PYTHON3_PACKAGES_PATH=~/.virtualenvs/cv3/lib/python3.4/site-packages \
    -D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4m.dylib \
    -D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/include/python3.4m \
    -D INSTALL_C_EXAMPLES=OFF \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D BUILD_EXAMPLES=ON \
    -D BUILD_opencv_python3=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..

Thank you for your help.

2016-10-10 11:09:10 -0600 commented question Get "non free" modules on OpenCV 2.4.13

Looking on the build>include folder I could not find the nonfree modules. So I have downloaded again the OpenCV 2.4.13. Now these modules are clearly there. Probably when I downloaded the first time by mistake I got the 3x versions but I was pretty sure to have downloaded this one. Sorry about these now it should work. Thank you for your time.

2016-10-10 06:44:02 -0600 commented question Get "non free" modules on OpenCV 2.4.13

So it seems to be that it is not a common problem, therefore or I made a really stupid mistake or there has been a problem setting the variables on Visual Studio and Windows.

Should I try to download a different version of OpenCV and set the path on Windows and Visual Studio?

2016-10-10 06:35:55 -0600 commented question Get "non free" modules on OpenCV 2.4.13

100% sure

2016-10-10 05:27:14 -0600 commented question Get "non free" modules on OpenCV 2.4.13

Visual Studio just underlines in red

#include "opencv2/nonfree/features2d.hpp"

and underlines all the classes used in the code obviously. Meaning that it cannot find these modules. The problem comes just when I try to include the nonfree module because for the rest of them it does not give me any errors.

2016-10-10 04:37:06 -0600 commented question Get "non free" modules on OpenCV 2.4.13

Well yes I guess, because I can use any of them except the nonfree ones.

2016-10-09 17:14:49 -0600 asked a question Get "non free" modules on OpenCV 2.4.13

Hi guys, I am new with OpenCV and probably this may seem a stupid question but I cannot access the following modules:

"opencv2/nonfree"

I am using C++ Visual Studio 2015 over Windows.

What do I have to do in order to access this library from my Visual Studio project?

Thank you for your patience.