-
Notifications
You must be signed in to change notification settings - Fork 312
Added classes and settings for supporting the new ThriftiestOV9281 Ca… #2478
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
Open
DoctorFogarty
wants to merge
6
commits into
PhotonVision:main
Choose a base branch
from
DoctorFogarty:ThriftiestCam
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c064f9f
Added classes and settings for supporting the new ThriftiestOV9281 Ca…
DoctorFogarty 82c09f0
Updated ThriftiestCam to support latest firmware changes
judsonjames 30c7aa0
Merge branch 'main' of https://github.com/photonvision/photonvision i…
judsonjames 95b0d19
Add back `setUpExposureProperties` method declaration
judsonjames b4977f6
Merge branch 'ThriftiestCam2026' of https://github.com/DoctorFogarty/…
judsonjames 62a5719
Update ThriftiestCam to support 2027 conventions
judsonjames File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...src/main/java/org/photonvision/vision/camera/USBCameras/ThriftyOV9281CameraSettables.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| * Copyright (C) Photon Vision. | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package org.photonvision.vision.camera.USBCameras; | ||
|
|
||
| import org.photonvision.common.configuration.CameraConfiguration; | ||
| import org.wpilib.util.PixelFormat; | ||
| import org.wpilib.vision.camera.UsbCamera; | ||
|
|
||
| public class ThriftyOV9281CameraSettables extends GenericUSBCameraSettables { | ||
|
|
||
| public ThriftyOV9281CameraSettables(CameraConfiguration configuration, UsbCamera camera) { | ||
| super(configuration, camera); | ||
| } | ||
|
|
||
| @Override | ||
| protected void setUpExposureProperties() { | ||
| super.setUpExposureProperties(); | ||
|
|
||
| // Fix the exposure lower and upper limits. | ||
| // The minimum usable exposure is above the UI default of 20, so | ||
| // the user is expected to increase exposure until the camera can | ||
| // pick up an image correctly. | ||
| this.minExposure = 1; | ||
| this.maxExposure = 2400; | ||
| } | ||
|
|
||
| @Override | ||
| public void onCameraConnected() { | ||
| super.onCameraConnected(); | ||
|
|
||
| // Filter out YUYV modes. The Sunplus SPCA2688 ISP's MJPEG encoder | ||
| // breaks permanently if a YUYV↔MJPEG format switch occurs. | ||
| // Only MJPEG modes (120fps) are usable; YUYV modes are 5-30fps anyway. | ||
| int originalSize = videoModes.size(); | ||
| videoModes.removeIf(m -> m.pixelFormat != PixelFormat.MJPEG); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OnCameraConnected is the first time video modes can be enumerated but perhaps the code that actually grabs video modes should be the thing to care here instead? Having stables mutate camera state feels like an anti pattern |
||
| if (videoModes.size() < originalSize) { | ||
| logger.info("Filtered to " + videoModes.size() + " MJPEG-only modes (YUYV removed)"); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void setAllCamDefaults() { | ||
| // Disable continuous autofocus BEFORE super tries to set focus_absolute | ||
| softSet("focus_automatic_continuous", 0); | ||
| super.setAllCamDefaults(); | ||
| logger.info("Setting All Cam Defaults :: ThriftyOV9281"); | ||
| softSet("focus_absolute", 0); | ||
| } | ||
|
|
||
| @Override | ||
| public void setAutoExposureImpl(boolean cameraAutoExposure) { | ||
| logger.debug("Setting auto exposure :: ThriftyOV9281 :: " + cameraAutoExposure); | ||
| if (autoExposureProp != null) { | ||
| autoExposureProp.set( | ||
| cameraAutoExposure ? PROP_AUTO_EXPOSURE_ENABLED : PROP_AUTO_EXPOSURE_DISABLED); | ||
| } | ||
| if (!cameraAutoExposure) { | ||
| setExposureRaw(this.lastExposureRaw); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a way to choose saner defaults based on camera model, or to use real units like milliseconds here