@zappar/zappar-cv 2.0.0-beta.8 → 2.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +2 -2
- package/lib/image-process-gl.d.ts +3 -1
- package/lib/image-process-gl.js +32 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -1
- package/umd/56.zappar-cv.js +1 -1
- package/umd/zappar-cv.js +1 -1
- package/umd/zappar-cv.worker.js +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -18,8 +18,8 @@ npm i @zappar/zappar-cv
|
|
|
18
18
|
|
|
19
19
|
You can use our CDN from within your HTML:
|
|
20
20
|
```
|
|
21
|
-
<script src="https://libs.zappar.com/zappar-cv/2.0.0-beta.
|
|
21
|
+
<script src="https://libs.zappar.com/zappar-cv/2.0.0-beta.9/zappar-cv.js"></script>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Or you can download and host our standalone JavaScript bundle:
|
|
25
|
-
[https://libs.zappar.com/zappar-cv/2.0.0-beta.
|
|
25
|
+
[https://libs.zappar.com/zappar-cv/2.0.0-beta.9/zappar-cv.zip](https://libs.zappar.com/zappar-cv/2.0.0-beta.9/zappar-cv.zip)
|
|
@@ -23,7 +23,9 @@ export declare class ImageProcessGL {
|
|
|
23
23
|
private _vertexBuffer;
|
|
24
24
|
private _indexBuffer;
|
|
25
25
|
private _greyscaleShader;
|
|
26
|
-
|
|
26
|
+
private _isWebGL2;
|
|
27
|
+
private _instancedArraysExtension;
|
|
28
|
+
constructor(_gl: WebGL2RenderingContext | WebGLRenderingContext);
|
|
27
29
|
resetGLContext(): void;
|
|
28
30
|
destroy(): void;
|
|
29
31
|
uploadFrame(texture: WebGLTexture, img: HTMLVideoElement | HTMLImageElement | ImageBitmap, rotation: number, fc: boolean): void;
|
package/lib/image-process-gl.js
CHANGED
|
@@ -17,6 +17,11 @@ export class ImageProcessGL {
|
|
|
17
17
|
this._framebufferHeight = 0;
|
|
18
18
|
this._framebufferId = null;
|
|
19
19
|
this._renderTexture = null;
|
|
20
|
+
this._isWebGL2 = false;
|
|
21
|
+
this._isWebGL2 = _gl.getParameter(_gl.VERSION).indexOf("WebGL 2") >= 0;
|
|
22
|
+
if (!this._isWebGL2) {
|
|
23
|
+
this._instancedArraysExtension = this._gl.getExtension("ANGLE_instanced_arrays");
|
|
24
|
+
}
|
|
20
25
|
}
|
|
21
26
|
resetGLContext() {
|
|
22
27
|
this._framebufferId = null;
|
|
@@ -36,6 +41,7 @@ export class ImageProcessGL {
|
|
|
36
41
|
const reenableDepthTest = gl.isEnabled(gl.DEPTH_TEST);
|
|
37
42
|
const reenableBlend = gl.isEnabled(gl.BLEND);
|
|
38
43
|
const reenableCullFace = gl.isEnabled(gl.CULL_FACE);
|
|
44
|
+
const reenableStencilTest = gl.isEnabled(gl.STENCIL_TEST);
|
|
39
45
|
const previousActiveTexture = gl.getParameter(gl.ACTIVE_TEXTURE);
|
|
40
46
|
const previousUnpackFlip = gl.getParameter(gl.UNPACK_FLIP_Y_WEBGL);
|
|
41
47
|
const previousProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
@@ -48,6 +54,7 @@ export class ImageProcessGL {
|
|
|
48
54
|
gl.disable(gl.DEPTH_TEST);
|
|
49
55
|
gl.disable(gl.BLEND);
|
|
50
56
|
gl.disable(gl.CULL_FACE);
|
|
57
|
+
gl.disable(gl.STENCIL_TEST);
|
|
51
58
|
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
|
|
52
59
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
53
60
|
const level = 0;
|
|
@@ -84,8 +91,22 @@ export class ImageProcessGL {
|
|
|
84
91
|
const previousTextureAttribNormalized = gl.getVertexAttrib(shader.aTextureCoordLoc, gl.VERTEX_ATTRIB_ARRAY_NORMALIZED);
|
|
85
92
|
const previousTextureAttribStride = gl.getVertexAttrib(shader.aTextureCoordLoc, gl.VERTEX_ATTRIB_ARRAY_STRIDE);
|
|
86
93
|
const previousTextureAttribOffset = gl.getVertexAttribOffset(shader.aTextureCoordLoc, gl.VERTEX_ATTRIB_ARRAY_POINTER);
|
|
87
|
-
const previousTextureAttribEnabled = gl.getVertexAttrib(shader.aTextureCoordLoc, gl.VERTEX_ATTRIB_ARRAY_ENABLED);
|
|
88
94
|
const previousTextureAttribBufferBinding = gl.getVertexAttrib(shader.aTextureCoordLoc, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
|
|
95
|
+
const previousTextureAttribEnabled = gl.getVertexAttrib(shader.aTextureCoordLoc, gl.VERTEX_ATTRIB_ARRAY_ENABLED);
|
|
96
|
+
let previousVertexAttribDivisor = 0;
|
|
97
|
+
let previousTextureAttribDivisor = 0;
|
|
98
|
+
if (this._isWebGL2) {
|
|
99
|
+
previousVertexAttribDivisor = gl.getVertexAttrib(shader.aVertexPositionLoc, gl.VERTEX_ATTRIB_ARRAY_DIVISOR);
|
|
100
|
+
previousTextureAttribDivisor = gl.getVertexAttrib(shader.aTextureCoordLoc, gl.VERTEX_ATTRIB_ARRAY_DIVISOR);
|
|
101
|
+
gl.vertexAttribDivisor(shader.aVertexPositionLoc, 0);
|
|
102
|
+
gl.vertexAttribDivisor(shader.aTextureCoordLoc, 0);
|
|
103
|
+
}
|
|
104
|
+
else if (this._instancedArraysExtension) {
|
|
105
|
+
previousVertexAttribDivisor = gl.getVertexAttrib(shader.aVertexPositionLoc, this._instancedArraysExtension.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
|
|
106
|
+
previousTextureAttribDivisor = gl.getVertexAttrib(shader.aTextureCoordLoc, this._instancedArraysExtension.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE);
|
|
107
|
+
this._instancedArraysExtension.vertexAttribDivisorANGLE(shader.aVertexPositionLoc, 0);
|
|
108
|
+
this._instancedArraysExtension.vertexAttribDivisorANGLE(shader.aTextureCoordLoc, 0);
|
|
109
|
+
}
|
|
89
110
|
// Rendering to the greyscale conversion buffer - bind the framebuffer
|
|
90
111
|
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
|
|
91
112
|
gl.viewport(0, 0, this._framebufferWidth, this._framebufferHeight);
|
|
@@ -121,6 +142,14 @@ export class ImageProcessGL {
|
|
|
121
142
|
gl.disableVertexAttribArray(shader.aVertexPositionLoc);
|
|
122
143
|
if (!previousTextureAttribEnabled)
|
|
123
144
|
gl.disableVertexAttribArray(shader.aTextureCoordLoc);
|
|
145
|
+
if (this._isWebGL2) {
|
|
146
|
+
gl.vertexAttribDivisor(shader.aVertexPositionLoc, previousVertexAttribDivisor);
|
|
147
|
+
gl.vertexAttribDivisor(shader.aTextureCoordLoc, previousTextureAttribDivisor);
|
|
148
|
+
}
|
|
149
|
+
else if (this._instancedArraysExtension) {
|
|
150
|
+
this._instancedArraysExtension.vertexAttribDivisorANGLE(shader.aVertexPositionLoc, previousVertexAttribDivisor);
|
|
151
|
+
this._instancedArraysExtension.vertexAttribDivisorANGLE(shader.aTextureCoordLoc, previousTextureAttribDivisor);
|
|
152
|
+
}
|
|
124
153
|
gl.bindFramebuffer(gl.FRAMEBUFFER, previousBoundFramebuffer);
|
|
125
154
|
gl.useProgram(previousProgram);
|
|
126
155
|
gl.bindTexture(gl.TEXTURE_2D, previousBoundTexture);
|
|
@@ -135,6 +164,8 @@ export class ImageProcessGL {
|
|
|
135
164
|
gl.enable(gl.DEPTH_TEST);
|
|
136
165
|
if (reenableScissorTest)
|
|
137
166
|
gl.enable(gl.SCISSOR_TEST);
|
|
167
|
+
if (reenableStencilTest)
|
|
168
|
+
gl.enable(gl.STENCIL_TEST);
|
|
138
169
|
}
|
|
139
170
|
readFrame(texture, pixels) {
|
|
140
171
|
let gl = this._gl;
|
package/lib/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ import { Additional } from "./additional";
|
|
|
3
3
|
import { Options } from "./options";
|
|
4
4
|
export declare type Zappar = zappar & Additional;
|
|
5
5
|
export declare function initialize(opts?: Options): Zappar;
|
|
6
|
-
export { zappar_image_tracker_t, zappar_instant_world_tracker_t, zappar_barcode_finder_t, zappar_face_tracker_t, zappar_face_landmark_t, barcode_format_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, log_level_t, zappar_face_mesh_t, zappar_pipeline_t, zappar_camera_source_t, zappar_sequence_source_t } from "./gen/zappar";
|
|
6
|
+
export { zappar_image_tracker_t, zappar_instant_world_tracker_t, zappar_barcode_finder_t, zappar_face_tracker_t, zappar_face_landmark_t, barcode_format_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, log_level_t, zappar_face_mesh_t, zappar_pipeline_t, zappar_camera_source_t, zappar_sequence_source_t, image_target_type_t } from "./gen/zappar";
|
package/lib/index.js
CHANGED
|
@@ -4,4 +4,4 @@ export function initialize(opts) {
|
|
|
4
4
|
console.log(`Zappar CV v${VERSION}`);
|
|
5
5
|
return nativeInitialize(opts);
|
|
6
6
|
}
|
|
7
|
-
export { barcode_format_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, log_level_t } from "./gen/zappar";
|
|
7
|
+
export { barcode_format_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, log_level_t, image_target_type_t } from "./gen/zappar";
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "2.0.0-beta.
|
|
1
|
+
export declare const VERSION = "2.0.0-beta.9";
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "2.0.0-beta.
|
|
1
|
+
export const VERSION = "2.0.0-beta.9";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zappar/zappar-cv",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.9",
|
|
4
4
|
"description": "Zappar's core computer vision library, supporting image, face and world tracking.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"build-standalone": "webpack --config=webpack.config.standalone.js --mode=production",
|
|
9
9
|
"build-standalone-debug": "webpack --config=webpack.config.standalone.js --mode=development",
|
|
10
10
|
"build-module": "tsc",
|
|
11
|
+
"tsc-watch": "tsc --watch",
|
|
11
12
|
"test-module": "jest puppeteer/module",
|
|
12
13
|
"test-standalone": "jest puppeteer/standalone",
|
|
13
14
|
"tests": "webpack --config=webpack.tests.config.js --mode=development && webpack serve --mode=development --config=webpack.tests.config.js",
|