mirror of
https://github.com/esimov/pigo-wasm-demos.git
synced 2025-12-24 12:47:56 +08:00
Updated demos
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
//go:build js && wasm
|
||||
// +build js,wasm
|
||||
|
||||
package bgblur
|
||||
|
||||
@@ -63,8 +62,8 @@ func NewCanvas() *Canvas {
|
||||
c.doc = c.window.Get("document")
|
||||
c.body = c.doc.Get("body")
|
||||
|
||||
c.windowSize.width = 768
|
||||
c.windowSize.height = 576
|
||||
c.windowSize.width = 1024
|
||||
c.windowSize.height = 640
|
||||
|
||||
c.canvas = c.doc.Call("createElement", "canvas")
|
||||
c.face = c.doc.Call("createElement", "canvas")
|
||||
|
||||
@@ -23,7 +23,7 @@ html, body {
|
||||
width: 80px;
|
||||
height: 40px;
|
||||
opacity: 0.8;
|
||||
right: 20%;
|
||||
right: 5%;
|
||||
top: 10%;
|
||||
z-index: 99;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build js,wasm
|
||||
//go:build js && wasm
|
||||
|
||||
package main
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ func NewCanvas() *Canvas {
|
||||
c.doc = c.window.Get("document")
|
||||
c.body = c.doc.Get("body")
|
||||
|
||||
c.windowSize.width = 768
|
||||
c.windowSize.height = 576
|
||||
c.windowSize.width = 1024
|
||||
c.windowSize.height = 640
|
||||
|
||||
c.canvas = c.doc.Call("createElement", "canvas")
|
||||
c.ellipse = c.doc.Call("createElement", "canvas")
|
||||
@@ -182,6 +182,7 @@ func (c *Canvas) StartWebcam() (*Canvas, error) {
|
||||
failure := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
|
||||
go func() {
|
||||
err = fmt.Errorf("failed initialising the camera: %s", args[0].String())
|
||||
fmt.Println(err)
|
||||
c.errCh <- err
|
||||
}()
|
||||
return nil
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build js,wasm
|
||||
//go:build js && wasm
|
||||
|
||||
package main
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ const (
|
||||
|
||||
minStrokeWidth = 0
|
||||
maxStrokeWidth = 4
|
||||
minScale = 200
|
||||
minScale = 170
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -83,8 +83,8 @@ func NewCanvas() *Canvas {
|
||||
c.doc = c.window.Get("document")
|
||||
c.body = c.doc.Get("body")
|
||||
|
||||
c.windowSize.width = 768
|
||||
c.windowSize.height = 576
|
||||
c.windowSize.width = 720
|
||||
c.windowSize.height = 480
|
||||
|
||||
c.webcamCanvas = c.doc.Call("createElement", "canvas")
|
||||
c.webcamCanvas.Set("width", c.windowSize.width)
|
||||
@@ -300,7 +300,7 @@ func (c *Canvas) drawDetection(data []uint8, dets [][]int) error {
|
||||
c.ctx.Set("lineWidth", 2)
|
||||
c.ctx.Set("strokeStyle", "rgba(255, 0, 0, 0.5)")
|
||||
|
||||
row, col, scale := det[1], det[0], int(float64(det[2])*0.8)
|
||||
row, col, scale := det[1], det[0], int(float64(det[2])*0.72)
|
||||
|
||||
leftPupil := pigo.DetectLeftPupil(det)
|
||||
rightPupil := pigo.DetectRightPupil(det)
|
||||
@@ -331,7 +331,7 @@ func (c *Canvas) drawDetection(data []uint8, dets [][]int) error {
|
||||
ty := p1[1] + (p1[1]-p2[1])/2 - int(maskHeight*0.5)
|
||||
|
||||
row += int(float64(row) * 0.02)
|
||||
col += int(float64(scale) * 0.3)
|
||||
col += int(float64(scale) * 0.4)
|
||||
|
||||
// Substract the image under the detected face region.
|
||||
imgData := make([]byte, scale*scale*4)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build js,wasm
|
||||
//go:build js && wasm
|
||||
|
||||
package main
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build js,wasm
|
||||
//go:build js && wasm
|
||||
|
||||
package main
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ func NewCanvas() *Canvas {
|
||||
c.doc = c.window.Get("document")
|
||||
c.body = c.doc.Get("body")
|
||||
|
||||
c.windowSize.width = 768
|
||||
c.windowSize.height = 576
|
||||
c.windowSize.width = 720
|
||||
c.windowSize.height = 480
|
||||
|
||||
c.canvas = c.doc.Call("createElement", "canvas")
|
||||
c.ellipse = c.doc.Call("createElement", "canvas")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// +build js,wasm
|
||||
//go:build js && wasm
|
||||
|
||||
package main
|
||||
|
||||
|
||||
@@ -83,8 +83,8 @@ func NewCanvas() *Canvas {
|
||||
c.doc = c.window.Get("document")
|
||||
c.body = c.doc.Get("body")
|
||||
|
||||
c.windowSize.width = 768
|
||||
c.windowSize.height = 576
|
||||
c.windowSize.width = 720
|
||||
c.windowSize.height = 480
|
||||
|
||||
c.canvas = c.doc.Call("createElement", "canvas")
|
||||
c.ellipse = c.doc.Call("createElement", "canvas")
|
||||
|
||||
Reference in New Issue
Block a user