Remove properties

This commit is contained in:
Milan Nikolic
2025-06-13 21:35:27 +02:00
parent f556285ad5
commit 26b04f44ad
3 changed files with 7 additions and 87 deletions

View File

@@ -285,15 +285,6 @@ func (c *Camera) Read() (img image.Image, err error) {
return
}
// GetProperty returns the specified camera property.
func (c *Camera) GetProperty(id int) float64 {
return 0
}
// SetProperty sets a camera property.
func (c *Camera) SetProperty(id int, value float64) {
}
// Close closes camera.
func (c *Camera) Close() (err error) {
ret := C.closeCamera()

View File

@@ -13,20 +13,6 @@ import (
im "github.com/gen2brain/cam2ip/image"
)
// Property identifiers.
const (
PropBrightness = v4l.CtrlBrightness
PropContrast = v4l.CtrlContrast
PropSaturation = v4l.CtrlSaturation
PropHue = v4l.CtrlHue
PropGain = v4l.CtrlGain
PropExposure = v4l.CtrlExposure
PropWhiteBalanceU = v4l.CtrlWhiteBalance
PropSharpness = v4l.CtrlSharpness
PropWhiteBalanceV = v4l.CtrlDoWhiteBalance
PropBacklight = v4l.CtrlBacklightCompensation
)
// Camera represents camera.
type Camera struct {
opts Options
@@ -113,18 +99,6 @@ func (c *Camera) Read() (img image.Image, err error) {
return
}
// GetProperty returns the specified camera property.
func (c *Camera) GetProperty(id int) float64 {
ret, _ := c.camera.GetControl(uint32(id))
return float64(ret)
}
// SetProperty sets a camera property.
func (c *Camera) SetProperty(id int, value float64) {
_ = c.camera.SetControl(uint32(id), int32(value))
}
// Close closes camera.
func (c *Camera) Close() (err error) {
if c.camera == nil {

View File

@@ -12,47 +12,9 @@ import (
im "github.com/gen2brain/cam2ip/image"
)
// Property identifiers.
const (
PropPosMsec = iota
PropPosFrames
PropPosAviRatio
PropFrameWidth
PropFrameHeight
PropFps
PropFourcc
PropFrameCount
PropFormat
PropMode
PropBrightness
PropContrast
PropSaturation
PropHue
PropGain
PropExposure
PropConvertRgb
PropWhiteBalanceU
PropRectification
PropMonocrome
PropSharpness
PropAutoExposure
PropGamma
PropTemperature
PropTrigger
PropTriggerDelay
PropWhiteBalanceV
PropZoom
PropFocus
PropGuid
PropIsoSpeed
PropMaxDc1394
PropBacklight
PropPan
PropTilt
PropRoll
PropIris
PropSettings
PropBuffersize
propFrameWidth = 3
propFrameHeight = 4
)
// Camera represents camera.
@@ -75,8 +37,8 @@ func New(opts Options) (camera *Camera, err error) {
err = fmt.Errorf("camera: can not open camera %d: %w", opts.Index, err)
}
camera.SetProperty(PropFrameWidth, opts.Width)
camera.SetProperty(PropFrameHeight, opts.Height)
camera.camera.Set(gocv.VideoCaptureProperties(propFrameWidth), opts.Width)
camera.camera.Set(gocv.VideoCaptureProperties(propFrameHeight), opts.Height)
return
}
@@ -86,17 +48,20 @@ func (c *Camera) Read() (img image.Image, err error) {
ok := c.camera.Read(c.frame)
if !ok {
err = fmt.Errorf("camera: can not grab frame")
return
}
img, err = c.frame.ToImage()
if err != nil {
err = fmt.Errorf("camera: %w", err)
return
}
if c.frame == nil {
err = fmt.Errorf("camera: can not retrieve frame")
return
}
@@ -111,16 +76,6 @@ func (c *Camera) Read() (img image.Image, err error) {
return
}
// GetProperty returns the specified camera property.
func (c *Camera) GetProperty(id int) float64 {
return c.camera.Get(gocv.VideoCaptureProperties(id))
}
// SetProperty sets a camera property.
func (c *Camera) SetProperty(id int, value float64) {
c.camera.Set(gocv.VideoCaptureProperties(id), value)
}
// Close closes camera.
func (c *Camera) Close() (err error) {
if c.camera == nil {