Comments (8)
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.
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.
Hi @blackjack Many thanks for the support. I will try to implement this way.
from webcam.
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.
Hi @blackjack yes, besides, I found another "sugar" of your idea in another repo.
Many thanks for the support.
from webcam.
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.
@mdlayher did you set camera format to JPEG (https://godoc.org/github.com/blackjack/webcam#Webcam.SetImageFormat)?
from webcam.
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)
- examples/http_mjpeg_streamer: it always set largest frame size
- USING IT FOR RPI CAMERA? HOT 1
- Error if `/dev/video0` file not present HOT 2
- Travis CI tests break due to math/bits package error on Go <1.9 HOT 1
- WaitForFrame times out on RPi (with LifeCam and RPi internal camera) HOT 4
- output to mp4
- UYVY format support HOT 1
- how to stream two cameras?
- add support for V4L2_PIX_FMT_MJPEG
- Question ! who can help me HOT 1
- add V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
- Invalid argument on capture
- Does not work on Pi OS anymore. Any plan to upgrade for the latest Raspberry Pi operating system? HOT 1
- Whired behaviour when returning frame `[]byte`
- Add support for unbuffered streaming HOT 1
- Webcam should prevent double close
- Request to become a maintainer or alternatively fork this library HOT 4
- Could this master version release? HOT 5
- v4l2.go / waitForFrame panics on "large" fds. HOT 2
- Request to cut a new release to include fd leak fix HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webcam.