banner



How To Acess The Camera Using Python In Windows Python

Arducam UVC cameras comply with UVC protocol and work with web-camera applications out-of-box. Merely avant-garde users might want to access these UVC cameras through their own code using Python and OpenCV with avant-garde controls for their car vision and AI applications. In this article, nosotros will cover how to access and control the Arducam UVC cameras in detail.

  1. 1.Capturing Video from UVC Web camera on Windows using Media Foundation
    • 1.1 Download the Simplecapture.exe file
    • 1.2 Unzip and open up the Simplecapture.exe file
    • i.3 Capture video
  2. 2.Access UVC Web Camera using OpenCV
    • 2.one How to install Python and OpenCV?
    • ii.2 Python lawmaking
  3. 3.Admission multiple UVC Spider web Camera
    • three.ane Modify device name and serial number
    • three.2 Python Code
  4. four.Troubleshooting
    • 4.1 Bank check camera part
    • 4.two Fail to access photographic camera
    • 4.3 Frame charge per unit cannot fix, and is too wearisome

ane.Capturing Video from UVC Web camera on Windows using Media Foundation

Yous can refer to this link for the source code.

ane.1 Download the Simplecapture.exe file

Download link:

https://www.codeproject.com/KB/audio-video/559437/SimpleCapture-exe.nix

ane.2 Unzip and open up the Simplecapture.exe file

image 38

Select File-Cull device-USB-OK

image 39

Select one the post-obit effigy listing. Click OK.

image 40

1.three Capture video

image 41

2.Admission UVC Web Camera using OpenCV

You can refer to the link as post-obit:

https://stackoverflow.com/a/606154
https://www.geeksforgeeks.org/python-opencv-capture-video-from-photographic camera/

Note

Delight utilize the version shown in the figure below and the upgraded version of OpenCV (the previous version of OpenCV mayhap cannot access the photographic camera ordinarily).

2.1 How to install Python and OpenCV?

Delight open up the collapsed content

1.Instll Python

Install Python on Windows delight refer to the following link:

https://realpython.com/installing-python/#how-to-install-python-on-windows

two.Install OpenCV

Open up cmd or PowerShell

Tip: How to open cmd

-Printing the Win key on your keyboard
-Blazon cmd
-Printing enter

Tip: How to open up PowerShell

-Press the Win key on your keyboard
-Type PowerShell
-Press enter

Enter the following command:

python -m pip install opencv-python

3.Run Python code or file

You tin can refer to the link.

  • Creat main.py file
  • Type Python lawmaking, such as print("Hullo World!")
  • Save file
  • Open the PowerShell/cmd window and switch the directory to the directory of the main.py file
  • Execute mian.py

ii.two Python code

import cv2   ''' apiPreference	preferred Capture API backends to use.  Tin can be used to enforce a specific reader implementation  if multiple are bachelor:  e.1000. cv2.CAP_MSMF or cv2.CAP_DSHOW. ''' # open up video0 cap = cv2.VideoCapture(0, cv2.CAP_MSMF) # set width and elevation # cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280) # cap.ready(cv2.CAP_PROP_FRAME_HEIGHT, 720) # gear up fps # cap.set(cv2.CAP_PROP_FPS, 30) while(True):     # Capture frame-past-frame     ret, frame = cap.read()     # Display the resulting frame     cv2.imshow('frame', frame)     if cv2.waitKey(ane) & 0xFF == ord('q'):         break  # When everything done, release the capture cap.release() cv2.destroyAllWindows()        

3.Access multiple UVC Web Photographic camera

3.1 Modify device name and series number

It is different from Linux, you lot need to identify your UVC cameras by device name when using multiple UVC cameras on windows. Please refer to the certificate to change Arducam UVC Camera series number.

Annotation: Different UVC cameras should have different device names and serial numbers.

After modified:

3.2 Python Code

from pymf import get_MF_devices device_list = get_MF_devices() for i, device_name in enumerate(device_list):     impress(f"opencv_index: {i}, device_name: {device_name}")

Note: Yous can refer to here to install pymf. Please exercise non install pymf using pip(the pymf in pip is unlike from download by yourself).

four.Troubleshooting

4.1 Cheque photographic camera function

Before using OpenCV to access the camera, you can bank check whether the camera is working properly through a graphical interface application firstly.

Way1 – You can refer to the doc to check your camera.

Way2 – You can apply the .exe file to check your camera, download, and how to use refer to the chapter.

4.two Fail to access camera

If you have the aforementioned problem, delight follow the steps below:

1.Switch API(cv2.CAP_MSMF or cv2.CAP_DSHOW).

2.Gear up a larger frame rate.

4.3 Frame charge per unit cannot set, and is too ho-hum

Using cv2.CAP_DSHOW API backends may see frame rates that cannot be set up and is at a very depression level. At this time, it is recommended to apply cv2.CAP_MSMF API backend.

Source: https://www.arducam.com/docs/uvc-camera-module/how-to-access-arducam-uvc-cameras-using-opencv-python-and-media-foundation-on-windows/

Posted by: bivonasagen1999.blogspot.com

0 Response to "How To Acess The Camera Using Python In Windows Python"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel