AsciiCam/C/include/capture.h
Harshit-Dhanwalkar 14cc7dcc2e Add macos support
2026-06-10 20:30:10 +05:30

34 lines
853 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef CAPTURE_H
#define CAPTURE_H
#include <stddef.h>
#include <stdint.h>
typedef struct webcam_impl webcam_impl_t;
typedef struct {
int fd; /* Linux: V4L2 fd. macOS: -1 (unused externally) */
int width;
int height;
void *buffer;
webcam_impl_t *impl;
} webcam_t;
// Initialize webcam
// On Linux: device = "/dev/video0"
// On macOS: device = NULL (uses system default camera) or a device name string
int webcam_init(webcam_t *cam, const char *device, int width, int height);
// Wait for frame to be ready
int webcam_wait_frame(webcam_t *cam, int timeout_ms);
// Capture frame, dequeue buffer, fill grayscale output buffer
int webcam_capture_frame(webcam_t *cam, uint8_t *gray_buffer);
// Requeue buffer
int webcam_requeue_buffer(webcam_t *cam);
// Stop streaming and clean up resources
void webcam_cleanup(webcam_t *cam);
#endif