Exemplo n.º 1
0
// GetImage sends bas64/image into stream
func GetImage(w http.ResponseWriter, r *http.Request) {
	params := getParams(r)
	if Session.Find(params["session_key"].(string)) {
		rawImage := camsnap.Get("/dev/video0", 1280, 720)
		imageEncoded := base64.StdEncoding.EncodeToString(rawImage)

		w.Header().Set("Content-Type", "image/jpeg")
		w.Header().Set("Content-Length", strconv.Itoa(len(imageEncoded)))
		w.WriteHeader(http.StatusOK)
		w.Write([]byte(imageEncoded))
	} else {
		w.WriteHeader(http.StatusForbidden)
	}
}
Exemplo n.º 2
0
func main() {
	raw := camsnap.Get("/dev/video0", 1280, 720)
	fmt.Println(raw[0:16])
}