Code Monkey home page Code Monkey logo

Comments (5)

carvilsi avatar carvilsi commented on May 22, 2024 1

Hi.

If your idea is not to use Flash, maybe you can try this (Fork of webcamJS):
https://github.com/carvilsi/webcamjs

Allows to choose a camera device.
Useful with mobile devices with front and back camera or PC with more than one camera attached.

In the "init" function we try to list and store on array "cameraIDs" all IDs of video devices, in your code you can check the length of this array and select one camera ID by "cameraID" variable before call "attach" function.

Something like that:

// webcam set, as usual
Webcam.set({
width: 150,
height: 150,
dest_width: 150,
dest_height: 130,
image_format: 'jpeg',
jpeg_quality: 90,
force_flash: false
});

// selecting camera device
if (Webcam.cameraIDs.length > 1) {
Webcam.cameraID = 1;
}

// attach, as usual
Webcam.attach('#camara');

If you use this, please, some feedback will be great ;)

Best regards.

from webcamjs.

jhuckaby avatar jhuckaby commented on May 22, 2024

I'm afraid I don't know how to provide a way to select the camera from inside the library. The way it works is that WebcamJS just asks for generic "camera" access, and the browser itself handles asking the user which camera. This is implementation dependent, as all browsers and HTML5 / Flash do it differently. Sorry!

from webcamjs.

rafverhaert avatar rafverhaert commented on May 22, 2024

Following code gives me an error because cameraID is undefined.
Webcamjs shows me the front camera but i need te camera on the back of my tablet

// selecting camera device
if (Webcam.cameraIDs.length > 1) {
Webcam.cameraID = 1;
}

from webcamjs.

cyphunk avatar cyphunk commented on May 22, 2024

@rafverhaert you have to use the fork version of the code which has the cameraid's array https://github.com/carvilsi/webcamjs/blob/master/webcam.js#L72

from webcamjs.

duydb avatar duydb commented on May 22, 2024

You can change camera by set value for capture attribute. At https://github.com/jhuckaby/webcamjs/blob/master/webcam.js#L367

See more capture options at: https://www.w3.org/TR/html-media-capture/

Ex:

      var input = document.createElement('input')
      input.id = this.container.id + '-ios_input'
      input.setAttribute('type', 'file')
      input.setAttribute('accept', 'image/*')
      input.setAttribute('capture', 'user')

=> Open front-camera

from webcamjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.