mirror of
https://github.com/comma-hacks/webrtc.git
synced 2025-10-30 19:16:19 +08:00
sidestep face ui ambition by using image
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
__pycache__
|
||||
secureput_identity.shelve
|
||||
/dist
|
||||
/secret.jpg
|
||||
26
face.go
26
face.go
@@ -1,10 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"image/draw"
|
||||
"image/jpeg"
|
||||
"image/png"
|
||||
"log"
|
||||
"os"
|
||||
"secureput"
|
||||
)
|
||||
|
||||
@@ -29,7 +32,12 @@ func (qrd *QrDisplay) GenPairInfo() {
|
||||
qrd.Img = image.NewRGBA(img.Bounds())
|
||||
draw.Draw(qrd.Img, img.Bounds(), img, image.Point{}, draw.Src)
|
||||
qrd.GeneratingQR = false
|
||||
log.Println("QR Code is in memory right now")
|
||||
err := WriteImageToFile(qrd.Img, "secret.jpg")
|
||||
if err != nil {
|
||||
log.Fatal(fmt.Errorf("face: save qr code to secret.jpg failed: %w", err))
|
||||
panic(err)
|
||||
}
|
||||
log.Println("QR Code written to secret.jpg")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,3 +54,19 @@ func (gui *Face) Changed() {
|
||||
func (gui *Face) Close() {
|
||||
log.Println("GUI closed")
|
||||
}
|
||||
|
||||
func WriteImageToFile(img *image.RGBA, filePath string) error {
|
||||
// Create a new file at the provided file path
|
||||
file, err := os.Create(filePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// Write the image to the file in PNG format
|
||||
if err := png.Encode(file, img); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
6
main.go
6
main.go
@@ -6,17 +6,17 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
signal := secureput.Create()
|
||||
signal := secureput.Create("go-webrtc-body")
|
||||
signal.Gui = &Face{app: &signal}
|
||||
go signal.RunDaemonMode()
|
||||
|
||||
if !signal.Paired() {
|
||||
go signal.Gui.Show()
|
||||
log.Println("Waiting to pair.")
|
||||
<-signal.PairChannel
|
||||
<-signal.PairWaitChannel
|
||||
}
|
||||
|
||||
go TestVisionIPCTrack("roadEncodeData")
|
||||
// go TestVisionIPCTrack("roadEncodeData")
|
||||
|
||||
for {
|
||||
select {}
|
||||
|
||||
Submodule signaling updated: 47709f4277...534077d858
Reference in New Issue
Block a user