Skip to content

Commit

Permalink
- add public api CaptureImage
Browse files Browse the repository at this point in the history
  • Loading branch information
DucNV2000 committed Oct 22, 2024
1 parent 0fd0ae3 commit 0924643
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 27 deletions.
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,15 @@ Capture camera image and save to a specified path.
[Full Documentation](https://blightue.github.io/CameraImageCapture/)

## Installation instructions
### Add the line below to `Packages/manifest.json`

### Unity package manager(Git)

1. Go to **Package Manager** window via `Window/Package Manager`
2. Click the **add** ![img](https://docs.unity3d.com/uploads/Main/iconAdd.png) button in the status bar
3. Select **Add package from git URL** from the add menu
4. Fill the git URL with https://github.com/blightue/UnityCameraImageCapture.git and click **Add**

### Unity package manager(Local)

1. Download and unzip the source code to your disk
2. Go to **Package Manager** window via `Window/Package Manager`
3. Click the **add** ![img](https://docs.unity3d.com/uploads/Main/iconAdd.png) button in the status bar
4. Select **Add package from disk** from the add menu
5. Select the **package.json** file in the unzipped folder
for version `1.0.0`
```csharp
"net.suisuishou.cameraimagecapture":"https://github.com/wolf-org/CameraImageCapture.git#1.0.0",
```

## Quick Start

### Version 0.5.0 Update:

Recommend use component **Capture with config**

Create a config asset by click the plus button in the Project window and follow `Camera Image Capture/Capturer config`
Expand Down
69 changes: 59 additions & 10 deletions RunTime/Photographer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,87 @@ namespace SuiSuiShou.CIC.Core
public static class Photographer
{
private static ImageCapture _imageCapture = new ImageCapture();

/// <summary>
/// Capture image resolution
/// </summary>
public static Vector2Int ImageResolution { get => _imageCapture.ImageResolution; set => _imageCapture.ImageResolution = value; }
public static Vector2Int ImageResolution
{
get => _imageCapture.ImageResolution;
set => _imageCapture.ImageResolution = value;
}

/// <summary>
/// Target camera for capturing
/// </summary>
public static Camera TargetCamera { get => _imageCapture.TargetCamera; set => _imageCapture.TargetCamera = value; }
public static Camera TargetCamera
{
get => _imageCapture.TargetCamera;
set => _imageCapture.TargetCamera = value;
}

/// <summary>
/// Image file write type
/// </summary>
public static WriteFileType WriteType { get => _imageCapture.WriteType; set => _imageCapture.WriteType = value; }
public static WriteFileType WriteType
{
get => _imageCapture.WriteType;
set => _imageCapture.WriteType = value;
}

/// <summary>
/// Image type
/// </summary>
public static ImageFormat ImageFormat { get => _imageCapture.ImageFormat; set => _imageCapture.ImageFormat = value; }
public static ImageFormat ImageFormat
{
get => _imageCapture.ImageFormat;
set => _imageCapture.ImageFormat = value;
}

/// <summary>
/// True for logging capture status
/// </summary>
public static bool IsLogCap { get => _imageCapture.IsLogCap; set => _imageCapture.IsLogCap = value; }
public static bool IsLogCap
{
get => _imageCapture.IsLogCap;
set => _imageCapture.IsLogCap = value;
}

/// <summary>
/// True for sequential image file name
/// </summary>
public static bool IsImageSerial { get => _imageCapture.IsImageSerial; set => _imageCapture.IsImageSerial = value; }
public static bool IsImageSerial
{
get => _imageCapture.IsImageSerial;
set => _imageCapture.IsImageSerial = value;
}

/// <summary>
/// True for changing ImageResolution in editor
/// </summary>
public static bool IsOverrideCameraResolution { get => _imageCapture.IsOverrideCameraResolution; set => _imageCapture.IsOverrideCameraResolution = value; }
public static bool IsOverrideCameraResolution
{
get => _imageCapture.IsOverrideCameraResolution;
set => _imageCapture.IsOverrideCameraResolution = value;
}

/// <summary>
/// Fold path for image file to writing
/// </summary>
public static string SaveFolderPath { get => _imageCapture.SaveFolderPath; set => _imageCapture.SaveFolderPath = value; }
public static string SaveFolderPath
{
get => _imageCapture.SaveFolderPath;
set => _imageCapture.SaveFolderPath = value;
}

/// <summary>
/// Image file name
/// </summary>
public static string FileName { get => _imageCapture.FileName; set => _imageCapture.FileName = value; }
public static string FileName
{
get => _imageCapture.FileName;
set => _imageCapture.FileName = value;
}

/// <summary>
/// Capture and save image file base on this singleton config
Expand All @@ -53,6 +97,11 @@ public static void CaptureAndSaveImage()
{
_imageCapture.CaptureAndSaveImage();
}

public static Texture2D CaptureImage(int depth)
{
return _imageCapture.CaptureImage(TargetCamera, ImageResolution, depth);
}
}

internal class ImageCapture : ICameraImageCaptureCore
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "net.suisuishou.cameraimagecapture",
"version": "0.6.5",
"version": "1.0.0",
"displayName": "CameraImageCapture",
"description": "Capture camera image and save to a specified path.",
"unity": "2020.1",
Expand Down

0 comments on commit 0924643

Please sign in to comment.