Skip to content

Commit

Permalink
Update for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
yushulx committed Dec 25, 2024
1 parent 263c835 commit 7d455e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
14 changes: 10 additions & 4 deletions litecam/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LiteCam

LiteCam is a lightweight, cross-platform library for capturing RGB frames from cameras and displaying them. Designed with simplicity and ease of integration in mind, LiteCam supports Windows and Linux platforms.
LiteCam is a lightweight, cross-platform library for capturing RGB frames from cameras and displaying them. Designed with simplicity and ease of integration in mind, LiteCam supports **Windows**, **Linux** and **macOS** platforms.

## Demo Video
- Linux Virtual Machine
Expand All @@ -24,6 +24,7 @@ LiteCam is a lightweight, cross-platform library for capturing RGB frames from c

- **Windows**: Uses Media Foundation for video capture.
- **Linux**: Uses Video4Linux (V4L2) and X11 for video capture and rendering.
- **macOS**: Uses AVFoundation for video capture.

## Requirements

Expand All @@ -43,7 +44,11 @@ LiteCam is a lightweight, cross-platform library for capturing RGB frames from c
sudo apt update
sudo apt install libx11-dev
```


### macOS
- Xcode
- Development libraries for AVFoundation (included with macOS)

## Installation

1. Clone the repository:
Expand Down Expand Up @@ -102,15 +107,16 @@ int main()
### API Overview
#### Camera
- **`std::vector<CaptureDeviceInfo> ListCaptureDevices()`**: Lists available video capture devices.
- **`bool Open(int cameraIndex)`**: Opens the camera with the specified index.
- **`bool SetResolution(int width, int height)`**: Sets the resolution for the camera.
- **`std::vector<MediaTypeInfo> ListSupportedMediaTypes()`**: Lists supported media types.
- **`FrameData CaptureFrame()`**: Captures a single RGB frame.
- **`void ReleaseFrame(FrameData &frame)`**: Releases the memory allocated for a frame.
- **`void Release()`**: Closes the camera and releases resources.
- **`void saveFrameAsJPEG(const char *filename, const unsigned char *rgbData, int width, int height)`**: Saves the frame as a JPEG image.
#### CameraWindow
- **`bool Create()`**: Initializes and creates a window.
- **`void Show()`**: Displays the window.
- **`bool WaitKey(char key)`**: Waits for user input; returns `false` if the specified key is pressed or the window is closed.
Expand Down
5 changes: 3 additions & 2 deletions litecam/dist/include/CameraPreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#elif __linux__
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#elif __APPLE__
#include <Cocoa/Cocoa.h>
// #elif __APPLE__
// #include <Cocoa/Cocoa.h>
#endif

// Export macro for shared library
Expand Down Expand Up @@ -66,6 +66,7 @@ class CAMERA_API CameraWindow
#elif __APPLE__
// Add macOS-specific members (e.g., NSWindow or CGContext)
void *nsWindow; // Use proper macOS data structures here
void *contentView;
#endif
};

Expand Down
Binary file added litecam/dist/lib/mac/liblitecam.dylib
Binary file not shown.

0 comments on commit 7d455e4

Please sign in to comment.