[Mobilar] Take a photo with its location information

资源一

Vue.js Tutorial: Learn to Build a Web App Quickly + Source Code

Vue.js Tutorial: Learn to Build a Web App Quickly

 

 

资源二

Location Based (GPS) Augmented Reality on the Web

貌似内置方向,比较重要。

 

 

资源三

vuejs geolocation and camera api photoTag

Codepen代码参考:https://gist.github.com/edwardlorilla/1d32b2f07350a365656d47052fdfad79

简单的方案。

 

 

资源四

从这里入手:

How to create a CAMERA APP in VueJS - Day 15#100DaysOfCode

 

 

资源五

https://codepen.io/ditarahma08/pen/GRRxZLW

how to convert codepen to vue?

 

 

 

 

各种问题


一、手机打开后,成了全屏

要求

a) 打开后置摄像头。

b) preview area可控。

复制代码
      <video
        v-show="!isPhotoTaken"
        ref="camera"
        :width="450"
        :height="337.5"
        autoplay
      ></video>

      <canvas
        v-show="isPhotoTaken"
        id="photoTaken"
        ref="canvas"
        :width="450"
        :height="337.5"
      ></canvas>
复制代码

 

方案

  • 读取video的frame。
let vc = null;
复制代码
function startCamera() {
  if (streaming) return;
  navigator.mediaDevices.getUserMedia({video: resolution, audio: false})
    .then(function(s) {
    stream = s;
    video.srcObject = s;
    video.play();
  })
    .catch(function(err) {
    console.log("An error occured! " + err);
  });

  video.addEventListener("canplay", function(ev) {
    if (!streaming) {
      height = video.videoHeight;
      width  = video.videoWidth;
      video.setAttribute("width", width);
      video.setAttribute("height", height);
      streaming = true;
      vc = new cv.VideoCapture(video);
    }
    startVideoProcessing();
  }, false);
}
复制代码
vc.read(src);

 

  • 处理后,写入result。
  cv.imshow("canvasOutput", result);

 

  • 再刷新canva。
<td>
    <canvas class="center-block" id="canvasOutput" width=320 height=240></canvas>
</td>

 

  • 后置摄像头配置
复制代码
async function startCamera() {
  const videoConstraints = {};
  videoConstraints.facingMode = 'environment';    // <---- open rear camera.

  let stream = await navigator.mediaDevices.getUserMedia({video: videoConstraints, audio: false});
  g_video.srcObject = stream;
  await g_video.play();

  setInterval(() => takeSnapshot(), 200);
}
复制代码

 

 

二、防止video自动全屏

设置为:inline模式

      <video
        v-show="!isPhotoTaken"
        ref="camera"
        :width="450"
        :height="337.5"
        autoplay playsinline muted
      ></video>

 

 

 

End.

 

posted @   郝壹贰叁  阅读(87)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示