EnoxSoftware / OpenCVForUnity

OpenCV for Unity (Untiy Asset Plugin)
https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088
558 stars 175 forks source link

Failed to open camera by VideoCapture(0) on editor #52

Closed mkstmyk closed 4 years ago

mkstmyk commented 5 years ago

I imported DlibFaceLandmarkDetectorWithOpenCVExample to a new project and just modified VideoCaptureExample to open(0) instead of open(video_filepath), but capture.isOpened() is false. It just shows black texture, seems it can't access to WebCam on my PC. I double checked its access by just running WebCamTextureExample in DlibFaceLandmarkDetector, and it seems OK. Could you tell me what am I missing? Thank you.

My environment is as follows: PC: iMac Mid2011 OS: macOS 10.13.6 Unity: 2018.2.5f1 OpenCVForUnity: 2.3.7 DlibFaceLndmarkDetector: 1.2.9

EnoxSoftware commented 5 years ago

Could you try the example using VideoCapteure.open(0) method? VideoCaptureSample.zip

mkstmyk commented 5 years ago

Thank you for your very quick response. I tried to run it even on the latest Unity (2019.2.11), but got no luck. Just in case, I also tried it on another machine (MacBook Pro 2015, OS X 10.11.6), but it also didn't work. isOpend() at line 69 of VideoCaptureSample.cs is always false on my environment. I checked the access to iSight and WebCam (Logitech C920) both on iMac and MacBook using PhotoBooth app and it seems working correctly. Do you have any suggestions to try? Thank you again.

EnoxSoftware commented 4 years ago

When I tried VideoCaptureSample.zip in my environment, it worked without problems. MacBook Pro 2015, OS X 10.14.4

VideoCapture_macOS0 14

However, when I tried it with a different macOS version ( MacBook Pro 2015, OS X 10.12 and OS X 10.13), it didn't work. Currently, the VideoCapteure.open (0) method does not seem to work under macOS 10.14. I'm now investigating the causes.

mkstmyk commented 4 years ago

Thank you very much for your investigation! I'll try to update the OS.

mkstmyk commented 4 years ago

It did work on macOS Mojave. Thank you again for your support!

mkstmyk commented 4 years ago

Hi @EnoxSoftware , sorry for bothering you again. I found another problem when I run your VideoCaptureSample on Unity 2019.2.17f1, Windows 10 w/ Logitech c920. Even though I explicitly set 1920x1080 resolution, capture.set (Videoio.CAP_PROP_FRAME_WIDTH, 1920); capture.set (Videoio.CAP_PROP_FRAME_HEIGHT, 1080); it returns lower image with black margins on both sides. screenshot Of course, I double checked WebCam settings by Logitech's tools. I really appreciate if you give me any hints or suggestions. Thank you very much in advance.