Coder Social home page Coder Social logo

westonganger / cordova-plugin-camera-preview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cordova-plugin-camera-preview/cordova-plugin-camera-preview

56.0 17.0 38.0 9.79 MB

Cordova plugin that allow camera interaction from HTML code

License: Apache License 2.0

Java 60.11% Objective-C 36.51% JavaScript 3.38%

cordova-plugin-camera-preview's Introduction

Cordova CameraPreview Plugin

Cordova plugin that allows camera interaction from HTML code.
Show camera preview popup on top of the HTML.

Features:

  • Start a camera preview from HTML code.
  • Drag the preview box.
  • Set camera color effect.
  • Send the preview box to back of the HTML content.
  • Set a custom position for the camera preview box.
  • Set a custom size for the preview box.
  • Set a custom alpha for the preview box.
  • Maintain HTML interactivity.

Installation:

cordova plugin add cordova-plugin-camera-preview
ionic plugin add cordova-plugin-camera-preview

Phonegap Build:

<gap:plugin name="cordova-plugin-camera-preview" />

Methods:

startCamera(options, successCallback, errorCallback)
Starts the camera preview instance.

When setting the toBack to TRUE, remember to add the style below on your app's HTML or body element:

html, body {
  background-color: transparent;
}

Javascript:

/* All options stated are optional and will default to values here */
CameraPreview.startCamera({x: 0, y: 0, width: window.device.width, height: window.device.height, camera: "front", tapPhoto: true, previewDrag: false, toBack: false});

stopCamera(successCallback, errorCallback)
Stops the camera preview instance.

CameraPreview.stopCamera();

takePicture(size, successCallback, errorCallback)
Take the picture, the parameter size is optional

CameraPreview.takePicture({maxWidth:640, maxHeight:640});

setOnPictureTakenHandler(successCallback, errorCallback)
Register a callback function that receives the image captured from the preview box.

CameraPreview.setOnPictureTakenHandler(function(picture) {
  document.getElementById('picture').src = picture; // base64 picture;
});

switchCamera(successCallback, errorCallback)
Switch from the rear camera and front camera, if available.

CameraPreview.switchCamera();

show(successCallback, errorCallback)
Show the camera preview box.

CameraPreview.show();

hide(successCallback, errorCallback)
Hide the camera preview box.

CameraPreview.hide();

setFlashMode(flashMode, successCallback, errorCallback)
Set the flash mode. Options are OFF, ON, AUTO

CameraPreview.setFlashMode('ON');

setColorEffect(colorEffect, successCallback, errorCallback)
Set the color effect.
iOS Effects: none, mono, negative, posterize, sepia.
Android Effects: none, mono, negative, posterize, sepia, aqua, blackboard, solarize, whiteboard

CameraPreview.setColorEffect('sepia');

setOnLogHandler(successCallback, errorCallback)

CameraPreview.setOnLogHandler(function(){
  console.log('log handler set!');
});

IOS Quirks:
It is not possible to use your computers webcam during testing in the simulator, you must device test.

Sample:
Cordova: cordova-plugin-camera-preview-sample-app for a complete working Cordova example for Android and iOS platforms.

Ionic: cordova-plugin-camera-preview-ionic-sample-app for a complete working Ionic example for Android and iOS platforms.

Android Screenshots:

cordova-plugin-camera-preview's People

Contributors

alexbonhomme avatar chancezeus avatar dustinthedev avatar fenkiou avatar flatt-dev avatar jacobweber avatar jtakalai avatar mbppower avatar rabbott2010 avatar rzeigler avatar scarych avatar shark0der avatar squio avatar stephan-nordnes-eriksen avatar toots avatar tushar-bidchat avatar westonganger 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

Watchers

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

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.