-
Notifications
You must be signed in to change notification settings - Fork 672
[cscore] Use frame time in Linux UsbCameraImpl #7609
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
Merged
Merged
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
81f509f
Use frame time in Linux UsbCameraImpl
mcm001 df32398
Don't narrow lol
mcm001 caa2234
Address review
mcm001 53c4121
fixup units
mcm001 5086ea8
update debug prints
mcm001 967259d
Remove unused variable
mcm001 ff589b8
pipe frame time source up
mcm001 4f10089
run lint on wpiutil
mcm001 e8ddd5a
actually pipe timetssamp up
mcm001 5d84182
mabe if I include what i use?
mcm001 fc49c3b
Expose frame time through JNI
mcm001 4422234
Add jni for frame time
mcm001 f32c283
Create test
mcm001 944cb58
update defaults
mcm001 e09e1fb
Fixup docs
mcm001 9ce9197
default init time
mcm001 c73d464
run lint and add javadocs
mcm001 8ccc844
spotbugs? more like spot periods
mcm001 2db2871
= 0 is apparently redundant
mcm001 80b45c3
make public
mcm001 81015d4
Empty commit
mcm001 36349ab
Add aphysical, totally bogus test hacks
mcm001 5da9d3c
Fixup enum caps
mcm001 02053ed
Kill ill-fated, untestable test
mcm001 b2ef7e5
Re-run CI
mcm001 30eb94e
Bro cannonical ur bad
mcm001 261adb8
Re-run ci
mcm001 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
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
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
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
65 changes: 65 additions & 0 deletions
65
cscore/src/test/java/edu/wpi/first/cscore/FrameTimeTest.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,65 @@ | ||
| // Copyright (c) FIRST and other WPILib contributors. | ||
| // Open Source Software; you can modify and/or share it under the terms of | ||
| // the WPILib BSD license file in the root directory of this project. | ||
|
|
||
| package edu.wpi.first.cscore; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import edu.wpi.first.cscore.raw.RawSink; | ||
| import edu.wpi.first.cscore.raw.RawSource; | ||
| import edu.wpi.first.util.PixelFormat; | ||
| import edu.wpi.first.util.RawFrame; | ||
| import edu.wpi.first.util.TimestampSource; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class FrameTimeTest { | ||
| @Test | ||
| void testFrameTimeRoundTrip() { | ||
| // Given a Source | ||
| RawSource source = new RawSource("foobar", PixelFormat.kBGR, 320, 240, 30); | ||
|
|
||
| // And a sink connected to it | ||
| RawSink sink = new RawSink("foobar2"); | ||
| sink.setSource(source); | ||
|
|
||
| // And as new frame with a non-zero time | ||
| RawFrame frame = new RawFrame(); | ||
| frame.setTimeInfo(12, TimestampSource.kV4lEoF); | ||
|
|
||
| // HACK (Matt): try putting a frame into the source to prime the tubes | ||
| assertDoesNotThrow(() -> Thread.sleep(10)); | ||
| source.putFrame(frame); | ||
| assertDoesNotThrow(() -> Thread.sleep(10)); | ||
|
|
||
| // And a sink waiting for a new frame to arrive | ||
| RawFrame sinkFrame = new RawFrame(); | ||
| Thread sinkGrabber = | ||
| new Thread( | ||
| () -> { | ||
| long ret = sink.grabFrame(sinkFrame, 10); | ||
| assertTrue(ret > 0); | ||
| }); | ||
| sinkGrabber.start(); | ||
|
|
||
| // When a new frame is added to the source | ||
| // (Note: the frame time and time source are overridden by RawSourceImpl, and changing this is | ||
| // spooky) | ||
|
||
| // (Matt: without this sleep, the test seemed flakey) | ||
| assertDoesNotThrow(() -> Thread.sleep(20)); | ||
| source.putFrame(frame); | ||
|
|
||
| // then the sink gets the image | ||
| assertDoesNotThrow(() -> sinkGrabber.join()); | ||
|
|
||
| // and the image time makes sense | ||
| assertTrue(sinkFrame.getTimestamp() > 0); | ||
| assertEquals(TimestampSource.kFrameDequeue, sinkFrame.getTimestampSource()); | ||
|
|
||
| frame.close(); | ||
| sink.close(); | ||
| source.close(); | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.