Python on Mac cannot access the webcam- Printable Version +- RoboDK Forum (//www.sinclairbody.com/forum) +-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN) + - - -论坛:通用RoboDK问题(//www.sinclairbody.com/forum/Forum-General-questions-about-RoboDK) +--- Thread: Python on Mac cannot access the webcam (/Thread-Python-on-Mac-cannot-access-the-webcam) |
Python on Mac cannot access the webcam-riddha-07-25-2020 I'm trying to control the offline robot using input from the camera. The program works well on my windows system. However, the program is not running on my Mac. It is able to open a video file though import cv2 cap = cv2.VideoCapture(0) #cap = cv2.VideoCapture('/Users/riddhamanna/Documents/RoboDK/ymaze.mp4') while(True): ret, img = cap.read() cv2.imshow('frame',img) if cv2.waitKey(1) & 0xFF == 27:#ord('q'): break cap.release() cv2.destroyAllWindows() print("Hello World!") RE: Python on Mac cannot access the webcam-Albert-07-25-2020 This issue is related to OpenCV. I believe the id of your camera is invalid. More information about error codes on Windows here: https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499- I'm moving this thread to the general questions section. RE: Python on Mac cannot access the webcam-riddha-07-25-2020 (07-25-2020, 05:34 PM)Albert Wrote:This issue is related to OpenCV. I believe the id of your camera is invalid. The same code is running perfectly from the python shell on mac. It is just not running from inside RoboDK. I do not have the problem on windows. RE: Python on Mac cannot access the webcam-Albert-07-27-2020 This problem is related to different Python versions. On Mac, RoboDK uses Python 2.7 by default (Mac's built-in Python version). You can use your default Python 3 version by just enteringpython3在the Python interpreter path (in Tools-Options-Python). RE: Python on Mac cannot access the webcam-riddha-07-29-2020 Did that. I have the latest versions installed. Not working. The same program can access videos from a file though. I guess on Mac it is some permissions issue. RoboDK cannot access the webcam. Can you kindly look into this? "Python script failed returning 6" Error code 6 is a SIGABRT error. Apparently the system is running into a fatal error and causing the program to abort(). RE: Python on Mac cannot access the webcam-riddha-08-29-2020 (07-27-2020, 03:39 PM)Albert Wrote:This problem is related to different Python versions. I haven't been able to solve this. The problem persists even with the latest RoboDK, and trying out every possible modification. I have also moved from the free version to a paid version. The same program runs on a windows system, but not on a mac. Also, the same code is running from the mac terminal, but not from inside RoboDK, so clearly this is a problem with RoboDK. Maybe it does not have permission to access the macbook camera? Kindly try to resolve this. Here is the code: import cv2 cap = cv2.VideoCapture(0) #this does not work on roboDK #cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640) #cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480) #cap = cv2.VideoCapture('/Users/riddhamanna/Documents/RoboDK/ymaze.mp4') #This works on roboDK while(True): ret, img = cap.read() cv2.imshow('frame',img) if cv2.waitKey(1) & 0xFF == 27:#ord('q'): break cap.release() cv2.destroyAllWindows() print("Hello World!") RE: Python on Mac cannot access the webcam-riddha-08-30-2020 Apparently you need to add something like this: to the info.plist file of RoboDK. But this is also not working. Basically, you need to modify the RboDK app to ask for permission to use the system camera/any camera on the MacOS. Can you kindly make this change in any future update? |