Code Monkey home page Code Monkey logo

wechat-miniprogram-webar's Introduction

  1. Chinese README

  2. Chinese Source Code Analysis

Updated

Date    Update
2019-08-16 Update: The project structure has been modified. The color tracker and object tracker are removed. Fix "access a camera" mode that does not work properly on Android.
2019-08-06 Fix Issue: When function "wx.canvasToTempFilePath" is called frequently on Android Wechat, WeChat will be crashed.
2019-08-01 Update: The perspective transform is achieved.
2019-07-15 Update: The NFT(Natural Feature Tracking) is achieved.
2019-07-08 New: The affine transform is achieved.

Introduction of WeChat MiniProgram Web AR

This is a WeChat Web AR Demo. On July 5, 2019, WeChat miniprogram supports AR. It has been added a new API named "CameraFrameListener".

CameraFrameListener API

We can create AR effects with the new API. This demo demonstrates a color tracker effect using "tracking.js" and "jsfeat" library.

The "tracking.js" brings computer vision algorithms and techniques into browser environment. We can do real-time color tracking, face detection and much more.

tracking.js

The "jsfeat" is a JavaScript computer vision library.

JSFeat

The Demo includes color tracker, face tracker, image tracker and object tracker. There are two modes for each item. It includes 'taking a photo' and 'access a camera'.

avatar

Face Tracker

Use the Demo to scan people's face.

avatar

Expect the effect below.

Use "Take a Photo" mode.

avatar

When face recognition is not exact, the result is not good.

avatar

When face recognition is exact, the result is good.

avatar

Image Tracker

a sample pattern picture is below.

avatar

Use the Demo to scan a rotate picture below.

avatar

Expected:

avatar

Use the Demo to scan a skew picture below.

avatar

Expected:

avatar

Use the Demo to scan a translate and scale picture below.

avatar

Expected:

avatar

Use the Demo to scan a perspective picture below.

avatar

Expected:

avatar

Color Tracker (Removed)

Use the Demo to scan the picture below.

avatar

Expect the effect below.

Use "Take a Photo" mode.

avatar

Use "Access a camera" mode.

avatar

Object Tracker (Removed)

There will be a rect aboves people's mouth. It is slow and not better than face tracker.

How to improve performance

Face tracker is slow, but we can do some thing to improve speed. For example, we can blur image, grayscale image, sobel image, compress image and so on. After testing, we found that reducing image size is more proper. When image size is reduced, the parameters of tracker needs to be updated.

frame size of camera: the image size is smaller, the tracker's speed is faster.

const frameWidth = 150;

face tracker parameter:the "initialScale" is bigger, the face tracker's speed is faster.

const initialScale = 2;

color tracker parameter:the "minDimension" is bigger, the color tracker's speed is faster.

const minDimension = 4;

interval time: interval time should be greater than cost time. The unit is milliseconds.

const intervalTime = 350;

Known Issues

Image tracker and face tracker are very slow on iOS WeChat.

wechat-miniprogram-webar's People

Contributors

sanyuered avatar

Watchers

James Cloos 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.