how use python code read video, not use openide

General discussion about topics related to OpenMV.
dotzhang
Posts: 2
Joined: Wed Nov 06, 2019 5:38 am

how use python code read video, not use openide

Postby dotzhang » Wed Nov 06, 2019 5:43 am

I try use python opencv read video, but fail, i only read mac camera, not read openmv video.
python code:

import cv2
# i try parameters use 0,1,2,3,4,5, but only 0 is available
video = cv2.VideoCapture(0)
test = video.isOpened()
# cv2.VideoCapture(0) output true, this is mac computer camera
# cv2.VideoCapture(1) output false
# cv2.VideoCapture(2) output false
print(test)
In OPENMV IDE, the camera is success, now i want use python read video, then show web pages. can this be done? What are some ways to use python read video? thanks.
User avatar
iabdalkader
Posts: 1180
Joined: Sun May 24, 2015 3:53 pm

Re: how use python code read video, not use openide

Postby iabdalkader » Wed Nov 06, 2019 10:58 am

Yes you can use the UVC firmware. Just keep in mind OpenMV is not meant to be used as a webcam.
dotzhang
Posts: 2
Joined: Wed Nov 06, 2019 5:38 am

Re: how use python code read video, not use openide

Postby dotzhang » Sat Nov 09, 2019 7:57 pm

iabdalkader wrote:
Wed Nov 06, 2019 10:58 am
Yes you can use the UVC firmware. Just keep in mind OpenMV is not meant to be used as a webcam.
If use the UVC firmware, this need modify openmv sourcecode ? Now, i already try use python uvc fireware read video, but always not find the camera, I was used cv2 read.
can you have through uvc read video example python code? thanks you very much.
User avatar
iabdalkader
Posts: 1180
Joined: Sun May 24, 2015 3:53 pm

Re: how use python code read video, not use openide

Postby iabdalkader » Mon Nov 11, 2019 6:22 pm

dotzhang wrote:
Sat Nov 09, 2019 7:57 pm
If use the UVC firmware, this need modify openmv sourcecode ? Now, i already try use python uvc fireware read video, but always not find the camera, I was used cv2 read.
can you have through uvc read video example python code? thanks you very much.
The UVC firmware is included in the IDE firmware folder, you just need to upload that instead and you don't need to modify source code. The camera will work like a webcam, you can use cv2 to read it. Note if you upload the UVC firmware the camera will no longer work with the IDE and it will not run Python it will just look like a webcam.
User avatar
kwagyeman
Posts: 4105
Joined: Sun May 24, 2015 2:10 pm

Re: how use python code read video, not use openide

Postby kwagyeman » Mon Nov 11, 2019 6:26 pm

A note, the bootloader will still be on the camera so you can still easily restore the normal firmware.

The UVC firmware is under <openmv-ide-install-dir>/share/qtcreator/firmware/OPENMV4/uvc.bin

Use the Tools->Run bootloader dialog to reflash the camera.
Nyamekye,
supported
Posts: 1
Joined: Thu Mar 19, 2020 12:08 am

Re: how use python code read video, not use openide

Postby supported » Thu Mar 19, 2020 12:31 am

There seems to be an issue with UVC firmware and macOS I can not get it to connect to camera in opencv. I have confirmed OPENMV4 is working as UVC device as it shows up in system profiler under cameras as

OpenMV Virtual Comm Port in FS Mode #2:

Model ID: UVC Camera VendorID_4617 ProductID_43985
Unique ID: 0x141300001209abd1


Also lsusb
Bus 020 Device 005: ID 1209:abd1 1209 OpenMV UVC in FS Mode Serial: 000000000011

I tried various programs to see if it is working as webcam such as Quick Time Player, Photo Booth and Plugable digital view. While all show the camera as an options none can connect to it.

I am using the Lepton 3 sensor which works fine with the normal firmware. I am currently using pyopenmv.py and normal firmware to get around this issue but it would be good to get UVC options working.
User avatar
kwagyeman
Posts: 4105
Joined: Sun May 24, 2015 2:10 pm

Re: how use python code read video, not use openide

Postby kwagyeman » Thu Mar 19, 2020 12:16 pm

Hi, this is an Ibrahim question. Note that the UVC firmware isn't really that supported. We did it because a customer thought it would be a cool idea. However, UVC doesn't have a JPEG stream option so it's hard to send lots of data over USB with it.
Nyamekye,
User avatar
iabdalkader
Posts: 1180
Joined: Sun May 24, 2015 3:53 pm

Re: how use python code read video, not use openide

Postby iabdalkader » Thu Mar 19, 2020 1:27 pm

supported wrote:
Thu Mar 19, 2020 12:31 am
There seems to be an issue with UVC firmware and macOS I can not get it to connect to camera in opencv. I have confirmed OPENMV4 is working as UVC device as it shows up in system profiler under cameras as

OpenMV Virtual Comm Port in FS Mode #2:

Model ID: UVC Camera VendorID_4617 ProductID_43985
Unique ID: 0x141300001209abd1


Also lsusb
Bus 020 Device 005: ID 1209:abd1 1209 OpenMV UVC in FS Mode Serial: 000000000011

I tried various programs to see if it is working as webcam such as Quick Time Player, Photo Booth and Plugable digital view. While all show the camera as an options none can connect to it.
Some programs show two UVC devices you have to try each one. Note this hasn't been tested on MacOS it's only known to work on Linux with guvcview.

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 2 guests