mirror of
				https://github.com/comma-hacks/webrtc.git
				synced 2025-10-31 19:42:39 +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__ | __pycache__ | ||||||
| secureput_identity.shelve | secureput_identity.shelve | ||||||
| /dist | /dist | ||||||
|  | /secret.jpg | ||||||
							
								
								
									
										26
									
								
								face.go
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								face.go
									
									
									
									
									
								
							| @@ -1,10 +1,13 @@ | |||||||
| package main | package main | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"fmt" | ||||||
| 	"image" | 	"image" | ||||||
| 	"image/draw" | 	"image/draw" | ||||||
| 	"image/jpeg" | 	"image/jpeg" | ||||||
|  | 	"image/png" | ||||||
| 	"log" | 	"log" | ||||||
|  | 	"os" | ||||||
| 	"secureput" | 	"secureput" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -29,7 +32,12 @@ func (qrd *QrDisplay) GenPairInfo() { | |||||||
| 		qrd.Img = image.NewRGBA(img.Bounds()) | 		qrd.Img = image.NewRGBA(img.Bounds()) | ||||||
| 		draw.Draw(qrd.Img, img.Bounds(), img, image.Point{}, draw.Src) | 		draw.Draw(qrd.Img, img.Bounds(), img, image.Point{}, draw.Src) | ||||||
| 		qrd.GeneratingQR = false | 		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() { | func (gui *Face) Close() { | ||||||
| 	log.Println("GUI closed") | 	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() { | func main() { | ||||||
| 	signal := secureput.Create() | 	signal := secureput.Create("go-webrtc-body") | ||||||
| 	signal.Gui = &Face{app: &signal} | 	signal.Gui = &Face{app: &signal} | ||||||
| 	go signal.RunDaemonMode() | 	go signal.RunDaemonMode() | ||||||
|  |  | ||||||
| 	if !signal.Paired() { | 	if !signal.Paired() { | ||||||
| 		go signal.Gui.Show() | 		go signal.Gui.Show() | ||||||
| 		log.Println("Waiting to pair.") | 		log.Println("Waiting to pair.") | ||||||
| 		<-signal.PairChannel | 		<-signal.PairWaitChannel | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	go TestVisionIPCTrack("roadEncodeData") | 	// go TestVisionIPCTrack("roadEncodeData") | ||||||
|  |  | ||||||
| 	for { | 	for { | ||||||
| 		select {} | 		select {} | ||||||
|   | |||||||
 Submodule signaling updated: 47709f4277...534077d858
									
								
							
		Reference in New Issue
	
	Block a user
	 Keyvan Fatehi
					Keyvan Fatehi