hiukim / mind-ar-js

Web Augmented Reality. Image Tracking, Face Tracking. Tensorflow.js
MIT License
2.13k stars 394 forks source link

Object remains when switch camera #410

Open coidergrobe opened 1 year ago

coidergrobe commented 1 year ago

I'm using mind ar threejs with react, I'm facing an issue that when my camera caught an object but then i use the switchCamera() method, the object remains on the screen instead of disappear. Can you have me with this issue Here is my code:

 const handleSwitchCamera = () => {
    if (mindArThreeRef.current) {
      mindArThreeRef.current.switchCamera()

      setIsUsingFrontCamera(!isUsingFrontCamera)
    }
  }
hiukim commented 1 year ago

Can you try v1.2.2 and see if problem still exists

coidergrobe commented 1 year ago

Can you try v1.2.2 and see if problem still exists

I tried, the problem still exists but i solved this problem with

mindArThreeRef.current.forEach((m) => {
        m.scene.visible = false
        m.switchCamera()
})

then set it back to true when anchor.onTargetFound()

innovacion-now commented 1 year ago

Hi!

I guess It's ok to follow this thread, If not apologies and I will open a new one. I'm not using react but I'm facing issues switching cameras on Android ( later I will try on IOS ) and ThreeJS example.

Is switchCamera() working with threeJs? I would like to test it with the threejs example ( https://hiukim.github.io/mind-ar-js-doc/more-examples/threejs-face-facemesh( )

Also start directly with the rear camera activated.

Right now I'm trying to do it once camera/system is already started -> Right after mindarThree.start();

const start = async() => {
  await mindarThree.start();
  mindarThree.switchCamera();
  ...

Error:

getUserMedia error DOMException: Could not start video source mindar-face-three.prod.js:25 Uncaught (in promise) undefined

I'm on Android 8.0 and Chrome 90.0.4430.66

pd: On desktop (using Chrome) seems to do something or at least no visible errors. First start the camera with some zoom, and after a while restarts the same camera ( I've two connected ) without zooming.

Cheers!

hiukim commented 5 months ago

yes, it should work on threejs. here is an example: https://github.com/hiukim/mind-ar-js/blob/master/examples/face-tracking/three.html