github.com/aamcrae/webcam@v0.0.0-20210915060337-934acc13bdc3/formats.go (about) 1 package webcam 2 3 import "fmt" 4 5 // Represents image format code used by V4L2 subsystem. 6 // Number of formats can be different in various 7 // Linux kernel versions 8 // See /usr/include/linux/videodev2.h for full list 9 // of supported image formats 10 type PixelFormat uint32 11 12 // Struct that describes frame size supported by a webcam 13 // For fixed sizes min and max values will be the same and 14 // step value will be equal to '0' 15 type FrameSize struct { 16 MinWidth uint32 17 MaxWidth uint32 18 StepWidth uint32 19 20 MinHeight uint32 21 MaxHeight uint32 22 StepHeight uint32 23 } 24 25 // Returns string representation of frame size, e.g. 26 // 1280x720 for fixed-size frames and 27 // [320-640;160]x[240-480;160] for stepwise-sized frames 28 func (s FrameSize) GetString() string { 29 if s.StepWidth == 0 && s.StepHeight == 0 { 30 return fmt.Sprintf("%dx%d", s.MaxWidth, s.MaxHeight) 31 } else { 32 return fmt.Sprintf("[%d-%d;%d]x[%d-%d;%d]", s.MinWidth, s.MaxWidth, s.StepWidth, s.MinHeight, s.MaxHeight, s.StepHeight) 33 } 34 }