forked from PhotonVision/photonvision
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Formatting cleanup, unit test cleanup (mocks for usb camera)
- Loading branch information
Showing
11 changed files
with
127 additions
and
81 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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
52 changes: 52 additions & 0 deletions
52
photon-core/src/test/java/org/photonvision/vision/processes/MockUsbCameraSource.java
This file contains 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,52 @@ | ||
package org.photonvision.vision.processes; | ||
|
||
import org.photonvision.common.configuration.CameraConfiguration; | ||
import org.photonvision.common.util.TestUtils; | ||
import org.photonvision.vision.camera.QuirkyCamera; | ||
import org.photonvision.vision.camera.USBCameraSource; | ||
import org.photonvision.vision.frame.provider.FileFrameProvider; | ||
|
||
public class MockUsbCameraSource extends USBCameraSource{ | ||
|
||
/** | ||
* Used for unit tests to better simulate a usb camera without a camera being present. | ||
*/ | ||
public MockUsbCameraSource(CameraConfiguration config, int pid, int vid) { | ||
super(config); | ||
|
||
getCameraConfiguration().cameraQuirks = QuirkyCamera.getQuirkyCamera(pid, vid, config.baseName); | ||
|
||
/** | ||
* File used as frame provider | ||
*/ | ||
usbFrameProvider = | ||
new FileFrameProvider( | ||
TestUtils.getWPIImagePath( | ||
TestUtils.WPI2019Image.kCargoStraightDark72in_HighRes, false), | ||
TestUtils.WPI2019Image.FOV); | ||
|
||
usbCameraSettables = new MockUsbCameraSettables(config); | ||
|
||
} | ||
|
||
private class MockUsbCameraSettables extends USBCameraSettables{ | ||
|
||
public MockUsbCameraSettables(CameraConfiguration config){ | ||
super(config); | ||
} | ||
|
||
/** | ||
* Hardware-specific implementation - do nothing in test | ||
*/ | ||
@Override | ||
public void setExposureRaw(double exposureRaw){} | ||
|
||
/** | ||
* Hardware-specific implementation - do nothing in test | ||
*/ | ||
@Override | ||
public void setAutoExposure(boolean cameraAutoExposure) {}; | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.