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

[RSDK-9864] Remove gostream middle-man dependency from webcam #4604

Open
wants to merge 72 commits into
base: main
Choose a base branch
from

Conversation

hexbabe
Copy link
Member

@hexbabe hexbabe commented Dec 5, 2024

RSDK-9864

Remove gostream middle-man dependency from webcam

Tested webcam on Mac and RPI4. Live and GetImage views on app. Unplug + replug on RPI4 (Logitech C90 Pro). Driver selection on app doesn't work anymore (as expected)

hexbabe and others added 30 commits October 24, 2024 14:59
…here we convert to go image; Change default mimetypes for classifier
…ng default mimetypes for vision since we are failing unit tests with 'do not know how to encode' errors
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 29, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 29, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 29, 2025
@hexbabe hexbabe changed the title Attempt to separate webcam and gostream entirely Webcam refactor Jan 29, 2025
@hexbabe hexbabe changed the title Webcam refactor RSDK-9630 Remove Old Discovery Logic (webcam) Jan 29, 2025
@hexbabe hexbabe changed the title RSDK-9630 Remove Old Discovery Logic (webcam) [RSDK-9630] Remove Old Discovery Logic (webcam) Jan 29, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 29, 2025
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 29, 2025
@hexbabe hexbabe changed the title [RSDK-9630] Remove Old Discovery Logic (webcam) [RSDK-9864] Remove gostream middle-man dependency from webcam Jan 29, 2025
@hexbabe hexbabe requested review from randhid and seanavery January 29, 2025 22:25
@hexbabe
Copy link
Member Author

hexbabe commented Jan 29, 2025

#4720 (comment) more context surrounding this ticket

@randhid
Copy link
Member

randhid commented Jan 30, 2025

Did it find the first driver it could connect to always? Try disabling and re-nable the webcam resource and a viam-server restart.

I'm good to go otherwise. We'll handle any new bugs in this new world.

@hexbabe
Copy link
Member Author

hexbabe commented Jan 30, 2025

Did it find the first driver it could connect to always? Try disabling and re-nable the webcam resource and a viam-server restart.

I'm good to go otherwise. We'll handle any new bugs in this new world.

Yeah it non-determinstically finds my iPhone or my builtin Mac webcam each disable+enable

return driver.Info{}, errors.Wrap(err, "cannot get driver from media source")
}
return d.Info(), nil
return nil, errors.New("NextPointCloud unimplemented")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we find a way to maintain PointCloud capabilities and the map of known intrinsics/extrinsics?

It's okay if it's dumb.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok if we don't 😖 I really don't like noopCloser

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the map of known intrinsics/extrinsics

Does the new GetProperties handle this? Or do you mean something else

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want a noop closer at all

here's what I'm thinking in pseudo code:

props, err := webcam.Properties(ctx, blah) , errcheck
switch 
case props.Intrinsics != nil :
        // call the rimage logic that makes pointclouds from images with a default Distortion Parameters, it can be found within the bowels on the videsource PointCloud method
case props.Intrinsics != nil && props.Distrotion != nil {
          // call the rimage logic that makes pointclouds from images with the camera's know Distortion Parameters, it can be found within the bowels on the videsource PointCloud method
default:
  error("NoPointCloud For YOU"
  }

}
}

for _, d := range needToClose {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just close the driver after getting Properties in the main loop?

Does not seem like that big of a deal if we need to open everything then close out afterwards as is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a reasonable suggestion... but I'm a bit hesitant touching this code since it's stuff copy and pasted from gostream. Feels a bit out of scope and could cause confusion since there's no git history of it being here. WDYT @randhid


// select implements SelectSettings algorithm.
// Reference: https://w3c.github.io/mediacapture-main/#dfn-selectsettings
func selectBestDriver(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the behavior of the driver matcher here change at all from previous code? Does it accept width, height, and framerate props that are not an exact fit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be the same since I copy pasted it from where it used to be referenced in gostream

cam, err := tryWebcamOpen(ctx, conf, path, false, constraints, logger)
if err != nil {
return nil, "", errors.Wrap(err, "cannot open webcam")
if conf.Width != 0 && conf.Height != 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be checking conf width and height here? Could the conf specify 0s but the driver that is matched has a valid size?

Copy link
Member Author

@hexbabe hexbabe Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're so right let me fix it to pull a frame regardless of config

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 30, 2025
return c.Images(ctx)
}
img, release, err := camera.ReadImage(ctx, c.underlyingSource)
img, release, err := c.reader.Read()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this ever released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.