Skip to content

Ivo/switch camera#249

Merged
thias15 merged 7 commits into
ob-f:masterfrom
izivkov:Ivo/swich-camera
Jan 13, 2022
Merged

Ivo/switch camera#249
thias15 merged 7 commits into
ob-f:masterfrom
izivkov:Ivo/swich-camera

Conversation

@izivkov

@izivkov izivkov commented Jan 8, 2022

Copy link
Copy Markdown
Contributor

No description provided.

@izivkov

izivkov commented Jan 8, 2022

Copy link
Copy Markdown
Contributor Author

In this PR:

  • Added button to the android and NodeJS controllers to switch bot camera remotely.
  • Minor fixes in nodejs code.
  • Updated documentation.

@izivkov izivkov changed the title Ivo/swich camera Ivo/switch camera Jan 8, 2022
function RemoteKeyboard (commandHandler) {
const pressedKeys = new Set()

// This deconstruction does not work. The functions are not called. Why?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is this supposed to do?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is not really critical, but in JS it is common to assign object properties to local variables, like this:

const {reset, goForward, goBackward, forwardLeft, forwardRight...} = commandHandler

is equivalent to:

const reset = commandHandler.reset

So, instead of calling:commandHandler.reset()we can just call:reset()

But in this case, if we call reset(), the function is not called. I was wondering why, because functions are first-class citizens in JS, and should be able to use them just like any other property. Maybe somebody can answer.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@thias15

thias15 commented Jan 12, 2022

Copy link
Copy Markdown
Collaborator

I noticed that it does not only toggle between front and back but actually goes through all cameras available on the phone. For example on the Huawei P30 Pro there are 4 cameras: back (ultrawide, normal, zoom), front (wide). Pressing the flip camera button toggles through these 4 options. It is actually nice to be able to pick any camera on the bot phone. But it is not really expected.

@izivkov

izivkov commented Jan 12, 2022

Copy link
Copy Markdown
Contributor Author

Interesting...
I looked into this a little bit deeper. It appears that we can implement our own CameraSwitchHandler by passing in into:
((CameraVideoCapturer) videoCapturer).switchCamera(null);
instead of passing null. Then we can select a camera by name. But I'm not sure we can do better than the default behaviour, since the camera names could change or vary across phones. What do you think?

@izivkov

izivkov commented Jan 12, 2022

Copy link
Copy Markdown
Contributor Author

Interesting... I looked into this a little bit deeper. It appears that we can implement our own CameraSwitchHandler by passing in into: ((CameraVideoCapturer) videoCapturer).switchCamera(null); instead of passing null. Then we can select a camera by name. But I'm not sure we can do better than the default behaviour, since the camera names could change or vary across phones. What do you think?

Actually, after running through the debugger, camera names are just "0", "1" ... So we do not know if they are front, back. macro, etc. They just select them in sequence. So I don't think we can chose specific camera, since we don't know what it is.

@thias15

thias15 commented Jan 12, 2022

Copy link
Copy Markdown
Collaborator

Should be possible to find out if it is front or rear camera.
https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#LENS_FACING

But I think it is also a nice feature to be able to toggle between the rear cameras. For driving it is good to use the ultra-wide camera. I guess the coolest would be if phone reports the available cameras and user can choose one. But maybe that is overkill. We could also merge now and look into this in a separate PR if you are interested to look into it.

@izivkov

izivkov commented Jan 12, 2022 via email

Copy link
Copy Markdown
Contributor Author

@thias15 thias15 merged commit 12c958c into ob-f:master Jan 13, 2022
lacykaltgr pushed a commit to satinavrobotics/SatiBot that referenced this pull request Jun 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants