Giter Site home page Giter Site logo

webcam-directive's Introduction

Webcam manipulation with HTML5

An AngularJS directive to manipulate the webcam.

Build Status

You can easily add it as a module to your own app.

A complete example can be found at http://jonashartmann.github.io/webcam-directive (gh-pages)

Download

NPM

Using NPM

npm install webcam

Using Bower

bower install webcam-directive

There is a tag for each version, with the built javascript file inside the dist directory

Ex.: dist/webcam.min.js

Installation

Using script tag

<script type="text/javascript" src="webcam.min.js"></script>

Usage

Add module "webcam" as dependency

angular.module('myapp', ['webcam']);

Then add the new element in HTML

<webcam></webcam>

Advanced Usage

Set a custom placeholder image to be shown while loading the stream

<webcam placeholder="'img/ajax-loader.gif'">

Callbacks

function MyController($scope) {
  $scope.onError = function (err) {...};
  $scope.onStream = function (stream) {...};
  $scope.onSuccess = function () {...};
}
<webcam
  on-stream="onStream(stream)"
  on-streaming="onSuccess()"
  on-error="onError(err)">
</webcam>

Set a channel to bind data

function MyController($scope) {
  $scope.myChannel = {
    // the fields below are all optional
    videoHeight: 800,
    videoWidth: 600,
    video: null // Will reference the video element on success
  };
}
<webcam
  channel="myChannel">
</webcam>

see more examples wiki

Contribute

  1. Fork and clone this repository

  2. Install dependencies

    npm install

  3. Build/test with grunt

    grunt test

  4. Make a Pull Request (it will only be merged if it passes the Travis build)

Or just help by creating issues.

Technologies used in this project

The code is licensed under the MIT License. @see LICENSE file

webcam-directive's People

Contributors

bmatsuo avatar bramski avatar evenfrost avatar jonashartmann avatar marcus2vinicius avatar mibamur avatar napiergit avatar seyfallahcheref avatar yoda-yoda avatar yono38 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webcam-directive's Issues

NotAllowedError: Permission denied in APP Android

I am having a permission error denied when accessing the webcam by the android application:

         <webcam channel="vm.channel"
                    on-streaming="vm.onSuccess()"
                    on-error="vm.onError(err)"
                    on-stream="vm.onStream(stream)"></webcam>

getting the entire video stream

Hi, I would like to use this module to get the video recorded from the webcam and save it to a server.
I saw the example of how capturing an image...any advice on how can I do to get the entire video?

Change video URL

Hi,

My channel:

    $scope.myChannel = {

    		// the fields below are all optional
    		videoHeight: 640,
    		videoWidth: 360,
    		video: null
    };  

My code:

<webcam on-stream="onStream(stream)" on-access-denied="onError(err)" on-streaming="onSuccess()" channel="myChannel" class="pull-right"></webcam>

When the video is created, it generates a URL, but my url is different.

<video class="webcam-live" autoplay src="blob:https://example.mydomain.com/23ee07ad-561e-4bg8-ac31" width="360" height="270"></video>

`

How could I change the src URL?

Not working with mozila

When I tried in mozila then I got this

navigator.mozGetUserMedia has been replaced by navigator.mediaDevices.getUserMedia
The following error occured: MediaStreamError { name: "NotReadableError", message: "Failed to allocate videosource", constraint: "", stack: "" }

Update version to be downloaded from the website

Canvas image to Base64

Hello @jonashartmann

First of all thanks for this great directive you wrote :)
I successfully able to implement your directive and was able to capture the image in a canvas. Now I want to upload that image to the server with a REST API which cosumes a Base64 image. Can you help me out how exactly I can upload that captures image ?

Thanks
Gaurav

Save Camera Data

Hi,
I'm sending the camera image byte to server using API, I'm using Java to save my file stream in server.
Could any one suggest to save that byte array using java code.

Thanks
Krishna

Safari support - none?

I haven't been able to get this to work on Safari (there is no prompt for access to the camera). Is there no Safari support?

Minified dist file isn't up to date

Hi @jonashartmann ,

I was making use of your webcam-directive package when I noticed that up until version 3.0.0, it would leave the webcam on even after the objects are destroyed.

This was fixed in 3.1.* but unfortunately the minified file wasn't generated with these fixes.

Any chance you could run the grunt script to generate it so it is generated upstream and so I don't have to hack around it myself? ๐Ÿ˜„ I could submit a pull request but considering we're talking about minified and hard to read code, it's probably better if it's generated by the project owner.

Cheers,
Tiago

camera device is locked failing to throw error

when camera is being used by another application Firefox throws this

"The following error occured: MediaStreamError { name: "NotReadableError", message: "Failed to allocate videosource", constraint: "", stack: "" }"

Which is good, but when i open an application that uses camera, then open chrome, i dont get this error so i dont know how to handle this, any advice?

video stream is not stopped

$scope.closed = function stopWebcam() {
onDestroy()
$scope.$broadcast('STOP_WEBCAM', stopWebcam);
$scope.$broadcast('$destroy', onDestroy);
}
var onDestroy = function onDestroy() {

    if (!!_video ) {
      var checker = typeof _video.getVideoTracks === 'function';
      if(_video.getVideoTracks && checker) {
        videoStream.stop();

        // get video track to call stop in it
        // videoStream.stop() is deprecated and may be removed in the
        // near future
        // ENSURE THIS IS CHECKED FIRST BEFORE THE FALLBACK
        // videoStream.stop()
        var tracks = _video.getVideoTracks();
        if (tracks && tracks[0] && tracks[0].stop) {
          tracks[0].stop();
        }
      } else if (_video.stop) {
        // deprecated, may be removed in the near future
        videoStream.stop();
      }
    }
    if (!!_video) {
      delete _video.src;
    }
  };

Improve testing of the directive code

The tests were really left behind because I could not imagine how to test that the webcam is being displayed, since that requires user interaction.
But there seem to be other parts of the code that could be tested.
The directive code may need some refactoring in order to make it more testable.

Video Undefined

i have to be missing something dumb here. in my on-streaming callback the passed in video param is always undefined even though i can see the video on the page. any ideas?

thanks!

Update demo version

Update the demo website (gh-pages branch) to use the latest commit, which supports the newest browser APIs.

Take snapshot as multipart

Hello,

I'm using webcam-directive to take a snapshot but I can't find how to take it as multipart. I only get base64 encoded format.

Is there a way to do it?

Thanks

how to emit events to stop start webcam

Hi there (I am busy, so the PR will be delayed :/)
However I have a quick question. You are listening for these events:

        $scope.$on('START_WEBCAM', startWebcam);
        $scope.$on('STOP_WEBCAM', stopWebcam);

I was not able to trigger them when switching the view with:

    $scope.$on('$ionicView.beforeLeave', function(){
        console.log("beforeleave");
        $scope.$emit('STOP_WEBCAM');

    });

I am new to angular, so I suppose I am doing something wrong here, maybe you can help :)

Set widht and height of video tag

Hi,

I don't know how to do it exactly, so can you explain if it is possible : I need to change the height and width of the video which is created by your directive (something like 240 x 300), but I can not figure it out how...

May you help me to do it? Thanks :)

bower install - not working with grunt bowerInstall

so basically grunt bowerInstall is generating a path of:

bower_components/webcam-directive/scripts/webcam.js

Which doesn't match up with whats on the filesystem. Not had time to look into this properly yet so apologies for sparse details.

Not a proper fix, but i'm being lazy, so just overrode it my MY bower.json:

   "overrides": {
    "webcam-directive": {
      "main": "dist/1.1.0/webcam.min.js"
    }
  }

Turn Camera On and Off

After I allow camera, its always turned on even if I go into different page (I can tell because there's always a red circle at the tab of my page). Is there any command that turns it on and off?

Angular 1.5 dependency

Does the directive work with angularjs version 1.5? I can see in bower.json that it requires angularjs ~1.4.0 which would only resolve to 1.4.x. If the library supports 1.5 then bower.json should mention >=1.4.0.

I have troubles installing the directive if angular 1.5 is added as a dependency in my bower.json because the correct version of angular cannot be resolved (my app wants 1.5 and webcam-directive needs 1.4).

Select Rear Camera in Android devices

This is more of a question than issue. By default if you are using Chrome on Android, the front camera is selected. Is there any way to select the rear camera via some options or controls? Thanks

save to file?

hello , how do i save the snapshot to a file?

thank you

"Failed to allocate videosource" error in Firefox

Currently if I go to the demo page in FireFox, the video stream will fail to start. Debugging though it, I get this error:

MediaStreamError {
    name: "SourceUnavailableError",
    message: "Failed to allocate videosource",
    constraintName: ""
}

I am using Firefox 36.0.4 (the latest as of right now). This may not be an issue with your JavaScript at all, I did find this recent bug report for Firefox which sounds related. Just letting you know if you're not aware.

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.