Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for OV9782 #1204

Closed
TheTripleV opened this issue Jan 28, 2024 · 3 comments · Fixed by #1284
Closed

Support for OV9782 #1204

TheTripleV opened this issue Jan 28, 2024 · 3 comments · Fixed by #1284
Labels
enhancement New feature or request

Comments

@TheTripleV
Copy link
Contributor

OV9782 is a color global shutter camera.

It's exposure range is 1-60.
It has hue, saturation, gamma, white balance, and contrast control.

The default white balance is pretty bad. 3500 is a better default.
The camera also supports auto white balance which seems to work well and changes near instantly.
It would be nice to have an updated white balance default, white balance slider, and a checkbox for auto whitebalance.

The camera has a reddish tinge (most noticeable around white lights and gray backgrounds). It never fully goes away but correcting white balance mostly resolves it

Potential performance improvement for apriltags: setting saturation to 0 on the sensor does spit out a grayscale image. If this is happening on the sensor itself, it would save on an op for apriltag mode.

output of lsusb for vid pid: ID 0c45:6366 Microdia Webcam Vitade AF

output of v4l2-ctl --all:

Driver Info:
	Driver name      : uvcvideo
	Card type        : Arducam OV9782 USB Camera: Ardu
	Bus info         : usb-fc800000.usb-1
	Driver version   : 5.10.160
	Capabilities     : 0x84a00001
		Video Capture
		Metadata Capture
		Streaming
		Extended Pix Format
		Device Capabilities
	Device Caps      : 0x04200001
		Video Capture
		Streaming
		Extended Pix Format
Media Driver Info:
	Driver name      : uvcvideo
	Model            : Arducam OV9782 USB Camera: Ardu
	Serial           : UC852
	Bus info         : usb-fc800000.usb-1
	Media version    : 5.10.160
	Hardware revision: 0x00000100 (256)
	Driver version   : 5.10.160
Interface Info:
	ID               : 0x03000002
	Type             : V4L Video
Entity Info:
	ID               : 0x00000001 (1)
	Name             : Arducam OV9782 USB Camera: Ardu
	Function         : V4L2 I/O
	Flags            : default
	Pad 0x01000007   : 0: Sink
	  Link 0x02000013: from remote pad 0x100000a of entity 'Extension 4' (Video Pixel Formatter): Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
	Width/Height      : 320/240
	Pixel Format      : 'MJPG' (Motion-JPEG)
	Field             : None
	Bytes per Line    : 0
	Size Image        : 154189
	Colorspace        : Default
	Transfer Function : Default (maps to Rec. 709)
	YCbCr/HSV Encoding: Default (maps to ITU-R 601)
	Quantization      : Default (maps to Full Range)
	Flags             : 
Crop Capability Video Capture:
	Bounds      : Left 0, Top 0, Width 320, Height 240
	Default     : Left 0, Top 0, Width 320, Height 240
	Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 320, Height 240, Flags: 
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 320, Height 240, Flags: 
Streaming Parameters Video Capture:
	Capabilities     : timeperframe
	Frames per second: 30.000 (30/1)
	Read buffers     : 0
                     brightness 0x00980900 (int)    : min=-64 max=64 step=1 default=0 value=0
                       contrast 0x00980901 (int)    : min=0 max=64 step=1 default=32 value=32
                     saturation 0x00980902 (int)    : min=0 max=128 step=1 default=90 value=90
                            hue 0x00980903 (int)    : min=-40 max=40 step=1 default=0 value=0
 white_balance_temperature_auto 0x0098090c (bool)   : default=1 value=0
                          gamma 0x00980910 (int)    : min=72 max=500 step=1 default=100 value=100
                           gain 0x00980913 (int)    : min=0 max=100 step=1 default=0 value=0
           power_line_frequency 0x00980918 (menu)   : min=0 max=2 default=2 value=2 (60 Hz)
				0: Disabled
				1: 50 Hz
				2: 60 Hz
      white_balance_temperature 0x0098091a (int)    : min=2800 max=6500 step=1 default=4600 value=4000
                      sharpness 0x0098091b (int)    : min=0 max=6 step=1 default=3 value=3
         backlight_compensation 0x0098091c (int)    : min=0 max=2 step=1 default=1 value=1
                  exposure_auto 0x009a0901 (menu)   : min=0 max=3 default=3 value=1 (Manual Mode)
				1: Manual Mode
				3: Aperture Priority Mode
              exposure_absolute 0x009a0902 (int)    : min=1 max=5000 step=1 default=157 value=1000
         exposure_auto_priority 0x009a0903 (bool)   : default=0 value=0
@TheTripleV TheTripleV added the enhancement New feature or request label Jan 28, 2024
@mcm001
Copy link
Contributor

mcm001 commented Jan 28, 2024

So exposure_absolute is actually 0-30 not 0-5000?

@TheTripleV
Copy link
Contributor Author

0-60. The max is in the 55-60 range but I can't tell the difference between those top few.

@mcm001
Copy link
Contributor

mcm001 commented Jan 30, 2024

gotcha, whoops typo. Anyways, great to confirm that it enumerates the same as other arducam cameras so we will need to do the same cameras tab hack as with the 2311/9281. should be super straight forwards to:

add a quirky camera
image
image

add it to the UI dropdown
image
image

and add the implementation with a check for if a camera has the OV9782 quirk to UsbCameraSource.java

Juniormunk added a commit that referenced this issue Jul 1, 2024
The OV9782 camera has a specific exposure range, so a camera quirk for
it needs to exist. The default white balance is also pretty bad, so it
must be adjusted.

Closes #1204

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
Co-authored-by: Cameron (3539) <theforgelover@gmail.com>
levyishai added a commit to laviRZ/photonvision that referenced this issue Aug 19, 2024
* Kill deprecated things (PhotonVision#1311)

* Change sim to use 36h11 tags when doing multitag (PhotonVision#1314)

* Undistort corner pitch/yaw using opencv (PhotonVision#1250)

* Undistort pitch/yaw

* Actually implement lol

* Update TargetCalculations.java

* fix yawpitch test units

* format

---------

Co-authored-by: amquake <noleetarrr@gmail.com>

* Bump libcamera to fix picam v1, remove duplicate opencv (PhotonVision#1263)

* Charuco Support (PhotonVision#1312)

Add charuco calibration to photonvision. Currently does not support generating custom charuco boards. This does not support https://calib.io/pages/camera-calibration-pattern-generator. Currently only supports the 4X4_50 family. Also removes all dotboard calibration. Fixes using the lowest possible fps while doing calibration (now uses the highest fps available for each resolution).

* Add sequence ID, capture, publish and recieve timestamp to PhotonPipelineResult (PhotonVision#1305)

Closes PhotonVision#1304

* Expose object detection class id/conf in photonlib (PhotonVision#1266)

* Implement class id/conf in photonlib

* Maybe fix things

* run lint

* Update Packet.java comments

* Update Packet.java comments again

* Update comments

* oops

* Update packet.py

---------

Co-authored-by: Chris Gerth <gerth2@users.noreply.github.com>

* Allow file uploads of any size and better report active cameras in PhotonCamera error print (PhotonVision#1298)

Previously reported itself which was confusing. New print:

```
Error at org.photonvision.PhotonCamera.verifyVersion(PhotonCamera.java:378): Found the following PhotonVision cameras active on NetworkTables:
 ==> HD_Pro_Webcam_C920
 ==> Arducam_OV9281_USB_Camera
```

* Disable Arm32 Builds (PhotonVision#1325)

Disables Arm32 builds and removes mention of the build option in the README.

* [PhotonLib C++] Fix SetVersionCheckEnabled to actually disable version checking (PhotonVision#1323)

* change verifyversion to use member variable

* Revert "change verifyversion to use member variable"

This reverts commit 4439839.

* Removed inline specifier for versioncheck variable

---------

Co-authored-by: Drew Williams <DrewW@iARx.com>

* Update README.md (PhotonVision#1321)

* Move PhotonVersion to C++ file (PhotonVision#949)

This was supposed to speed up incremental compilation, but not sure it actually does. It's better form tm tho and fixes a robotpy-wrapper weirdness

* Bump wpilib to latest dev (PhotonVision#1327)

* Publish generated proto sources (PhotonVision#1328)

* Disable transitive deps for rknn-jni (PhotonVision#1329)

* Update maven URL to reposilite (PhotonVision#1330)

Also bumps to new builds of artifacts (NFC)

* Allow opencv8 distortion model in PhotonCamera (PhotonVision#1317)

We previously assumed only OpenCV5 but mrcal uses opencv8

* Fix mac released jar naming (PhotonVision#1332)

* Change default AprilTag family to 36h11 (PhotonVision#1333)

Change default AprilTag family to 36h11

Resolves PhotonVision#1226

* Warn when getBestCameraToTarget returns 0, 0, 0 (PhotonVision#1334)

Resolves PhotonVision#915

* Fix libcamera not found bug (PhotonVision#1326)

* Update build.yml

* Camera Lost Stream (PhotonVision#1341)

* Fix no stream on camera unplug.

* Spotless remove datarate

* Make Static Frames Class

* lint and format

* Add photon.pb.h/PhotonVersion to cpp headers zip & create combined sources zip (PhotonVision#1335)

Combined sources zip is useful for robotpy to build both targeting & lib in the same build

* Create combine job and offline vendordep ZIP (PhotonVision#1343)

* Create combine job

* Update build.yml

* Bump max workers in photonlib

* Oops

* actually kill entirely

* Maybe fix test

* Don't run tests

* Update OpenCVTest.java

* Update build.yml

* Use upload-artifact@v4

* Update build.yml

* Update build.yml

* Only download necessary files in release step (PhotonVision#1344)

* Only publish to maven on main fork (PhotonVision#1345)

* Bump libcamera driver version (PhotonVision#1346)

* Update build.gradle

* Revert "Warn when getBestCameraToTarget returns 0, 0, 0 (PhotonVision#1334)" (PhotonVision#1351)

This reverts commit 6ff7b3e. See PhotonVision#1351 for context

* fix CSI camera null quirks error (PhotonVision#1349)

temp fix for this issue with csi cameras

* Support more charuco boards (PhotonVision#1348)

Add support for the old opencv charuco board like calibio. 

Add support for other tag families while calibrating.

Fix calibration issue index out of range with charuco missing points.

* Bump wpilib to 2025.0.0-alpha-1 and break non-FRC JDKs (PhotonVision#1356)

Windows users will have to add
`"-Dorg.gradle.java.home=C:\Users\Public\wpilib\2024\jdk"` to gradle
invocations, ie `./gradlew run
"-Dorg.gradle.java.home=C:\Users\Public\wpilib\2024\jdk"`, due to MSVC
ABI breakages and other stupidity

* Move docs in-source (PhotonVision#1357)

* Rename .readthedocs to match RTD

* Adds support for OV9782's quirks (PhotonVision#1284)

The OV9782 camera has a specific exposure range, so a camera quirk for
it needs to exist. The default white balance is also pretty bad, so it
must be adjusted.

Closes PhotonVision#1204

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
Co-authored-by: Cameron (3539) <theforgelover@gmail.com>

* Fix OV9782 typos (PhotonVision#1358)

There were a couple of typos in the last OV9782 fix, this addresses
those. Additionally, remove Matt's comment that he forgot.

* Update docs on docs about docs (PhotonVision#1360)

* Use pnpm instead of npm (PhotonVision#1375)

Pnpm is like npm except instead of keeping multiple copies of
dependencies, it shares a single copy for multiple dependencies
significantly reducing build time and the space needed to hold all the
dependencies. Read [here](https://pnpm.io/motivation) for more info.

This changes our CI to use pnpm and allows developers to choose to use
pnpm instead of npm. Also, pnpm has a built-in node version manager so
devs no longer need to use nvm to work on photonvision. All npm
functionality (including photon-server gradle tasks) still functions
using npm so this isn't breaking. We should make a docs change to
suggest to use pnpm.

* Fixed spelling error (PhotonVision#1376)

* Revert "Use pnpm instead of npm" (PhotonVision#1382)

Reverts PhotonVision#1375

Causes white screen UI Bug, "the way we currently strap everything with
vue2 and vuetify has a lot of footguns in it, and using a newer package
manager where each subdependency gets its own version of node is causing
incorrect dependency resolution which also means we can't fix this
without either updating node or patching those dependencies id say just
revert the PR for now until I or someone else can do the vue3 update"

* Run wpiformat  (PhotonVision#1379)

* Use new OrangePi5 images and add OrangePi5 Pro (PhotonVision#1388)

* Use ReadQueue for PhotonCamera timestamps (PhotonVision#1316)

This removes the extra GetLastChange call to keep everything properly
atomic.

Closes PhotonVision#1303

* Add API docs to sidebar (PhotonVision#1383)

* Add rsync & sphinx-autobuild docs (PhotonVision#1391)

* Update install.sh for OPi5 Ubuntu 24.04 (PhotonVision#1390)

This updates the install script to work correctly on Ubuntu 24.04
versions of the Orange Pi 5 images.

Changes include:
- installing libatomic1
- disabling networkd-wait-online if using Network Manager
- using systemctl instead of service to detect if photonvision is
running
- detecting if this is a RK3588 cpu and enabling all cores

* Move to using Absolute Exposure Range (PhotonVision#1352)

Uses logic in
PhotonVision/photon-libcamera-gl-driver#16 to
push the ov9281 down to its true minimum exposure.

Updates UI to list the exposure settings in ~~microseconds.~~ Native
units - not everyone works in microseconds.

Does its darndest to actually try to set the exposure in
~~microseconds.~~ Native Units. To do this...

Lifecam is funky when doing this - [cscore limits the exposure settings
to certain quantized
values](https://github.com/wpilibsuite/allwpilib/blob/main/cscore/src/main/native/linux/UsbCameraImpl.cpp#L129).
Add a new camera quirk to allow that.

~~Updated camera quirks to re-evaluate every camera load (rather than
recalling from settings - this shouldn't be necessary)~~ This should be
rolled back, needed for arducam type selection.

Updated camera quirk matching logic to make PID/VID optional, and
basename optional (and only match trailing characters). This enables
mirroring CSCore's logic for identifying lifecams by name.

Updated the USBCamera to primarily use cscore's exposed property names.

Since camera manufacturers use a potpourri of names for the same
thing....

For nice-to-have settings: new soft-set logic to try all possible names,
but gracefully pass if the property isn't there.
For required settings: Search a list for the first setting that's
supported, fail if none are supported.

More logging of camera properties to help debug.

Note: most of this work is because cscore doesn't directly expose a
massaged exposure-setting-absolute API (and, given what we've seen,
probably _shouldn't_, this struggle is not for the faint of heart).

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>

* Add OrangePi5b image to generated images (PhotonVision#1394)

* Document how to install PhotonLib of specific version (PhotonVision#1392)

* Fixed PipelineManager logic

* spotless

* Error fixes

* cameraExposure -> cameraExposureRaw

* Trying reverting some changes

* Revert "Trying reverting some changes"

This reverts commit f3faf80.

---------

Co-authored-by: Matt <matthew.morley.ca@gmail.com>
Co-authored-by: Drew Williams <williams.r.drew@gmail.com>
Co-authored-by: amquake <noleetarrr@gmail.com>
Co-authored-by: Programmers3539 <bbprogrammers3539@gmail.com>
Co-authored-by: Chris Gerth <gerth2@users.noreply.github.com>
Co-authored-by: Craftzman7 <zezetta@icloud.com>
Co-authored-by: Drew Williams <DrewW@iARx.com>
Co-authored-by: Jade <spacey-sooty@proton.me>
Co-authored-by: Cameron (3539) <theforgelover@gmail.com>
Co-authored-by: Gautam <gautamparanjape8@gmail.com>
Co-authored-by: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com>
Co-authored-by: MADMAN-Modding <115199645+MADMAN-Modding@users.noreply.github.com>
Co-authored-by: Craig Schardt <crschardt@fastem.com>
Co-authored-by: vic123 <38455236+victkk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants