Ask Your Question

Hardin's profile - activity

2016-09-19 02:35:37 -0600 received badge  Notable Question (source)
2016-03-01 09:24:22 -0600 received badge  Popular Question (source)
2015-04-12 01:28:20 -0600 asked a question Mouse events in a mac?

Hello and thanks always.

I have written this very simple python program:

import cv2
import numpy as np

def draw_circle(event,x,y,flags,param):
    if event==cv2.EVENT_LBUTTONDBLCLK:
        cv2.circle(img,(x,y),100,(255,0,0),-1)

#create a black image, a windows and bind the fuction to the window

img=np.zeros((512,512,3),np.uint8)
cv2.namedWindow('image')
cv2.circle(img,(10,10),10,(0,255,0),-1)
cv2.setMouseCallback('image',draw_circle)

while(1):
    cv2.imshow('image',img)
    if cv2.waitKey(20)&0xFF==27:
        break

cv2.destroyAllWindows()

And although I have tested it on a windows machine and works without problems when I tried it on my mac, all I got is a black window and the program does not seem to respond to the mouse or pad commands.

What is my mistake here? Can anyone help me on this

Thanks a lot

2015-03-30 09:15:09 -0600 received badge  Supporter (source)
2015-03-29 09:16:59 -0600 asked a question OpenCV with Python on a mac

Hello everybody. I would appreciate if someone can help me with this.

I have installed Opencv with python on a windows PC. No problem, I am trying to do the same on a mac. (snow leopard)

However, I did the following: -Installed python 2.7 ( i know mac comes with python but i got recommended that i had to reinstall it) -Installed Numpy

So if I do something like "import numpy as np" in python, no problem.

Then I wanted to install opencv and the only option seemed MacPorts so I installed Macports and then did the

sudo port install opencv +python2.7 (sorry I dont remember exactly the grammar now)

Well, it seems that opencv is working. I made a program in C++ and build it and could get to display a jpg in a window. So no problem my opencv is working for C++

now I try to do that with python but even though I make import cv2 I get

import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named cv2

What should I do for python to recognize my opencv??

Thanks a thousand

F.Y.I I did the following: $port select python Available versions for python: none (active) python25-apple python26-apple python27

$ port installed opencv The following ports are currently installed: opencv @2.4.11_0+python27 (active)