webcam

package
v0.0.0-...-13b120a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoStartOfImage = fmt.Errorf("image/jpeg start mark not detected")
	ErrNoEndOfImage   = fmt.Errorf("image/jpeg end mark not detected")
)

Functions

func ResetConnectivity

func ResetConnectivity(db *sqlx.DB) error

Types

type Camera

type Camera struct {
	ID              int    `db:"id" json:"id"`
	SensorID        int    `db:"sensor_id" json:"sensor_id"`
	Title           string `db:"title" json:"title"`
	Description     string `db:"description" json:"description"`
	DescriptionLong string `db:"description_long" json:"description_long"`

	Hostname        string           `db:"hostname" json:"hostname"`
	ProjectName     string           `db:"project_name" json:"project_name"`
	StorageLocation string           `db:"storage_location" json:"storage_location"`
	Interval        int              `db:"interval" json:"interval"`
	NextCapTureTime pgtype.Timestamp `db:"next_capture_time" json:"next_capture_time"`
	Status          string           `db:"status" json:"status"`
	Alert           bool             `db:"alert" json:"alert"`
	Active          bool             `db:"active" json:"active"`

	CreatedAt string            `db:"created_at" json:"created_at"`
	UpdatedAt helper.NullString `db:"updated_at" json:"updated_at"`

	DB *sqlx.DB `json:"-"`
	// contains filtered or unexported fields
}

func GetCameraByID

func GetCameraByID(id int, db *sqlx.DB) (Camera, error)

func GetCameraList

func GetCameraList(db *sqlx.DB) ([]*Camera, error)

func NewCameraWithDB

func NewCameraWithDB(db *sqlx.DB) Camera

NewCamera instantiates a new camera struct with db connection.

func (*Camera) CaptureTimelapseImage

func (c *Camera) CaptureTimelapseImage(timelapse StreamTimelapse)

func (*Camera) DeleteCamera

func (c *Camera) DeleteCamera() (int64, error)

func (*Camera) InsertNewCamera

func (c *Camera) InsertNewCamera() (Camera, error)

func (*Camera) Online

func (c *Camera) Online() bool

Online checks if the camera is online and returning true by checking if status code is 200.

func (*Camera) SetNextCaptureTime

func (c *Camera) SetNextCaptureTime() error

SetNextCaptureTime sets the next capture time for a given camera based on interval, and replaces the value in the struct. Interval is in seconds.

func (*Camera) UpdateCamera

func (c *Camera) UpdateCamera() (Camera, error)

type StreamTimelapse

type StreamTimelapse struct {
	StorageDir  string
	Hostname    string
	ProjectPath string
	ProjectName string
	JsonConfig  string
	// contains filtered or unexported fields
}

StreamTimelapse is a struct that holds the configuration for a timelapse project.

func NewTimelase

func NewTimelase(storageDir string, hostname string, projectName string) (StreamTimelapse, error)

NewTimelapse either opens or creates a new timelapse project.

func (*StreamTimelapse) CaptureTimelapseImage

func (s *StreamTimelapse) CaptureTimelapseImage() error

CaptureTimelapseImage captures a single image from stream and saves it to the project folder. The image is saved as a jpeg file with the name: <unix-timestamp>-image.jpg to prevent overwriting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL