Comments (8)
Unfortunately I don't know of a native way to do this. There doesn't appear to be an API to get the camera dimensions in either getUserMedia (HTML5) or in Adobe Flash. The best way I've found to deal with this is to always capture in 4:3 aspect ratio, and then crop your desired rectangle/square out of the center of the image after capture (using HTML5 Canvas, or on the server using GD or ImageMagick).
I may add an API to do this for you, in an upcoming version of WebcamJS.
from webcamjs.
There's videoHeight and videoWidth attributes on a video element, which you can use to calculate the aspect ratio.
from webcamjs.
mfkp, thanks.
I found, how to do it, but the only problem is that I can't calculate it before I attach the camera and start streaming.
from webcamjs.
You might need to start it up, get the video element, calculate the aspect ratio, then do Webcam.reset() and initialize it again with the new values.
Could be a better way to do it, but nothing is coming to mind right now.
from webcamjs.
A bit weird way, but it's the only thing came to my ming too.
For my purpose I've saved videoH and videoW, and after making a snapshot do some math to resize taken image to proportional size
(By the way, about resize() method - Look at the issue #25
There are some troubles and I solved it, but I can't commit changes)
from webcamjs.
Looks like videoWidth / videoHeight are only available with getUserMedia (Chrome & Firefox only). I don't see a way to do it with the Flash fallback (Safari / IE). For now, I'm going to try my "post-crop" idea, and will continue to look at a universal way to support this. Thanks guys.
from webcamjs.
Hey guys, I have implemented an automatic "crop" feature which can be used if you want to capture a square image. The idea is, the engine will capture at 4:3 aspect ratio (as 99.99999% of all webcams support that), but then it'll crop a square (or any rectangle shape) out of the center for you, all handled automatically in the background, and reflected in the live preview as well.
Live Demo: http://pixlcore.com/demos/webcamjs/demos/crop.html
from webcamjs.
Live demo shows an error :(
from webcamjs.
Related Issues (20)
- Webcam.js Error: No supported webcam interface found HOT 2
- Demo Website Not Working in Chrome, Works in IE and Microsoft Edge HOT 2
- On the problem that the func function in snap function is undefined
- Webcam Not working for IE11 in React project HOT 1
- No supported webcam interface is found
- I am using webcam.js plugin to use camera in web app. But i am not getting solution for choose front or rear camera choice. please give me some solution to use camera choice. HOT 1
- Iphone open device camera instead of web camera
- How to turn off after snapshat?
- Capture webcam in IE11 HOT 2
- webcam.js displays black screen on initialization in android webview
- webcam.swf's allowDomain * detected as potential vulnerability HOT 1
- Unable to switch to rear camera even after using facingMode as environment (On Android mobiles) HOT 5
- Webcam.js Error: Could not access webcam: NotAllowedError: Permission denied NotAllowedError: Permission denied
- Remove Red Icon on browser tab HOT 1
- Webcam.Snap firing more than once
- Facial guideline on canvas
- Edge Mobile (Android) requires video.play();
- Plain Green image returned on some android devices
- When webcam node is hidden, live images are not getting captured properly in safari HOT 1
- Demo links are broken HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webcamjs.