我正在使用Webcam.min.js库来捕获图像。当我水平地使用Tablet时,它就正常工作了。但是,当我做平板垂直,然后相机不旋转。
我的代码是:
<script type="text/javascript" src="../assets/webcam.min.js"></script>
<h4>Take picture</h4>
<div style="float:left;">
<div id="my_camera"></div>
<input type="button" id="snap" value="Take Snapshot" ng-click="ctrl.take_snapshot()">
</div>
<div style="display: inline-block;margin-top: -35px;;margin-left: 30%;;" id="results">Your captured image will appear here...</div>脚本代码:
Webcam.set({
width: 320,
height: 240,
image_format: 'jpeg',
jpeg_quality: 90,
flip_horiz: true,
constraints: {
video: true,
facingMode: "environment"
}
});
Webcam.attach( '#my_camera' );
this.take_snapshot= function take_snapshot() {
// take snapshot and get image data
Webcam.snap( function(data_uri) {
// display results in page
document.getElementById('results').innerHTML =
'<h5>Captured on : '+new Date()+'</h5>' +
'<img src="'+data_uri+'"/>';
alert(data_uri);
} );
}我费了很大劲才把它修好。但没有运气。
发布于 2019-04-16 05:02:24
我想我有一个解决方案,相机偏好时,使用手机。
不推荐使用navigator.getUserMedia函数,而应该使用较新的MediaDevices.getUserMedia函数。文档的链接。
在您的Threex.ArToolkitSource.js文件行中,143应更改为
var constraints = { video: {
facingMode: "environment"
mandatory: {
maxWidth: _this.parameters.sourceWidth,
maxHeight: _this.parameters.sourceHeight
}
};如果有人想要使用‘自拍’相机,他们会将“环境”改为“用户”。你甚至可以做一个按钮来选择两者之间的选择。
然而,这可能会导致您更改大量代码。
https://stackoverflow.com/questions/55700790
复制相似问题