Giter VIP home page Giter VIP logo

Comments (8)

blackjack avatar blackjack commented on August 22, 2024

Image in a byte array that is received by webcam.GetImg("/dev/your_webcam") will be in YUV format.
First you have to convert YUV to RGB using formula
R = Y + 1.140V
G = Y - 0.395U - 0.581V
B = Y + 2.032U

And then save the image as JPEG using https://golang.org/pkg/image/jpeg/#Encode

I cannot give you exact code snippet right now, but will try to do it today.

from webcam.

blackjack avatar blackjack commented on August 22, 2024

I think you can even define image straight in YUV color mode using https://golang.org/src/image/color/ycbcr.go?s=2328:2366#L72

from webcam.

jabrena avatar jabrena commented on August 22, 2024

Hi @blackjack Many thanks for the support. I will try to implement this way.

from webcam.

blackjack avatar blackjack commented on August 22, 2024

I just want to state that this library in current state is not really suitable to reliably work with webcam (better way is maybe use OpenCL bindings for that. But since it looks like it's pretty popular already (21 star on github) I maybe will have to prettify it :)

from webcam.

jabrena avatar jabrena commented on August 22, 2024

Hi @blackjack yes, besides, I found another "sugar" of your idea in another repo.
Many thanks for the support.

from webcam.

mdlayher avatar mdlayher commented on August 22, 2024

Hi @blackjack , very cool library. I too am looking for a way to spit out a single JPEG image from a webcam.

I've tried reading a single frame and attempting to write it out as a JPEG image, but I keep running into a variety of errors. Is there a simple way to make this work?

Thanks for your time.

from webcam.

blackjack avatar blackjack commented on August 22, 2024

@mdlayher did you set camera format to JPEG (https://godoc.org/github.com/blackjack/webcam#Webcam.SetImageFormat)?

from webcam.

blackjack avatar blackjack commented on August 22, 2024

Oops, sorry, I didn't understand you correctly.
So first, you have to look at the formats your webcam supports.
If there's MJPEG format, grab a frame from camera and just save it - it should be a valid JPEG image. Otherwise you have to convert received frame to JPEG by yourself.

from webcam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.