A couple of comments here... The error I'm seeing when trying to run OpenCV from my MacOS development environment Is:
I know those words originate from the OpenCV library here. My initial thought was that this was an OpenCV issue. With a bit more testing I think it's something else. As others have noted, MacOS security / permissions issue. But here's the rub. If I go to Mac Apple Icon (Upper Left Corner) --> Systems Preferences --> Security and Privacy I can glean a lot of info. Check on the Camera Icon. In my case this shows two applications which require additional permissions to get access to the camera, Terminal and Virtualbox (not sure what happens to browser, Facetime?) I do note, Xcode didn't make this list. When I click over to Microphone, I see different apps listed, INCLUDING Xcode. How does that even work? I did do a whole lot of testing, including researching modifying the
Info.plist for the Xcode application package (Finder --> Applications Folder --> Xcode --> Rt click, Show Package Contents. Copy Info.plist save it elsewhere, modify it via Xcode, resubmit.) Note: Don't try this without keeping a copy of the original Info.plist. Total fail. Adding the This whole thing is baffling. Why does Apple allow us to access the camera via terminal but not in Xcode? What's the logic there? I sure would like to be able to step thru code to understand frame by frame possible design issues. This just isn't fun. So a couple of things to understand.
I start my OpenCV project with:
It's a hack work around, but better than nothing. (Sure wish Apple included the camera in iOS emulator, that would be another way to solve this, sigh.) Obviously a lot depends on where you are going with your project. Ultimately I need mine to run on an iPad; Proveout on MacOS, then wrap code in Swift, etc... For reference, I'm using macOS Mojave, 10.14.4, MacBook 2.7GHz i7 PS. The security preferences above doesn't show Chrome with Camera access. Seems odd. I just tested the camera at this site... in Chrome, and it asks for permission and works exactly as expected. Its not clear on what's going on here. PS2. Am I the only person to file a bug report on this issue? Link included for your convenience. Thanks. Đã đăng vào thg 12 23, 2019 1:30 SA 3 phút đọc Hôm nay mình sẽ hướng dẫn các bạn cài đặt OpenCV4 trên MacOS Bước 1: Cài đặt Xcode: Để cài đặt Xcode chỉ cần vào Apple App Store tìm ứng dụng Xcode và tiến hành cài đặt. Sau khi Xcode được cài đặt thì chúng ta cần chấp nhận những điều khoản. Mở Terminal và chạy lệnh sau:
Hãy chấp nhận những điều khoản, sau đó cài đặt Apple Command Line (việc này là bắt buộc), nên bạn có thể cài đặt tools bên dưới:
Click vào install để cài đặt. Bước 2: Cài đặt Homebrew: Để cài đặt Homebrew bạn có thể dùng qua lệnh sau thông qua Terminal:
Tiếp theo là cập nhật Homebrew:
Tiếp theo chỉnh sửa bash_profile bằng lệnh:
Đến đây ta sẽ vào chỉnh sửa file bash_profile. Thêm PATH sau vào cuối file:
Bấm Ctrl + X để thoát nano. Bạn sẽ nhận được cảnh báo có lưu file không. Hãy nhớ lưu lại. Sau đó chạy lệnh:
Bước 4: Cài đặt các điều kiện tiên quyết bằng Homebrew: Cài đặt python 3.6: Tại sao lại là python 3.6. Vì python 3.7 không hỗ trợ Keras mặc dù có hỗ trợ Tensorflow nhưng cũng không khuyến khích cài đặt python 3.7 vậy để tránh trường hợp dùng thư viện mà lại có lỗi không mong muốn nên cũng không phải là sự lựa chọn tốt cho OpenCV. Lệnh bên dưới là để cài python 3.6.5_1:
Sau đó xác nhận xem python đã được cài đặt chưa:
Kết quả:
Hãy xác nhận lận nữa:
nếu bạn thấy Hãy dành chút thời gian cho việc kiểm tra xem bạn dùng python của Homebrew hay hệ thống. Hãy cài những điều kiện tiên quyết tiếp theo OpenCV yêu cầu một vài điều kiện trước khi được cài đặt. Bạn sẽ cài đặt những gói sau:
Cài đặt wget:
Phần tiếp theo sẽ hơi dài nên mình tách ra làm 2 phần. Phần 2: https://viblo.asia/p/huong-dan-cai-dat-opencv-4-len-macos-phan-2-924lJqJ8ZPM Nguồn: https://www.pyimagesearch.com/2018/08/17/install-opencv-4-on-macos/ All rights reserved |