Skip to content

Commit d82d474

Browse files
committed
Support setting/getting control values
1 parent 935a1cc commit d82d474

File tree

4 files changed

+108
-8
lines changed

4 files changed

+108
-8
lines changed

BayerPattern.cs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,29 @@
22

33
namespace TianWen.DAL
44
{
5-
[Flags]
6-
public enum BayerPattern
5+
public enum BayerPattern : ulong
76
{
8-
Monochrome = 0,
9-
HasBayerMatrix = 1,
10-
RGGB = 0b0000_0010 | HasBayerMatrix,
11-
BGGR = 0b0000_0100 | HasBayerMatrix,
12-
GBRG = 0b0000_1000 | HasBayerMatrix,
13-
GRBG = 0b0001_0000 | HasBayerMatrix,
7+
// TYPE
8+
Monochrome = 0b00,
9+
R = 0b001,
10+
G = 0b010,
11+
B = 0b011,
12+
L = 0b100, // Luminance (Kodak Truesense)
13+
E = 0b101, // Emerald
14+
15+
RGGB = R << 9 | G << 6 | G << 3 | B,
16+
BGGR = B << 9 | G << 6 | G << 3 | R,
17+
GBRG = G << 9 | B << 6 | R << 3 | G,
18+
GRBG = G << 9 | R << 6 | B << 3 | G,
19+
20+
/// <summary>
21+
/// Native BIN1 pattern of Sony IMX294 sensors (QHY294C-PRO).
22+
/// </summary>
23+
RRGG_RRGG_GGBB_GGBB =
24+
R << 45 | R << 42 | G << 39 | G << 36 |
25+
R << 33 | R << 30 | G << 27 | G << 24 |
26+
G << 21 | G << 18 | B << 15 | B << 12 |
27+
G << 9 | G << 6 | B << 3 | B
1428
}
1529

1630
public static class BayerPatternEx

CMOSControlType.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace TianWen.DAL
2+
{
3+
public enum CMOSControlType
4+
{
5+
Gain = 1,
6+
Exposure,
7+
Gamma,
8+
WB_R,
9+
WB_B,
10+
Brightness,
11+
BandwidthOverload,
12+
Overclock,
13+
TemperatureDeci,// return 10*temperature
14+
Flip,
15+
AutoMaxGain,
16+
AutoMaxExp,
17+
AutoMaxBrightness,
18+
HardwareBin,
19+
HighSpeedMode,
20+
CoolerPowerPerc,
21+
TargetTemp,// not need *10
22+
CoolerOn,
23+
MonoBin,
24+
FanOn,
25+
PatternAdjust,
26+
AntiDewHeater,
27+
Humidity,
28+
EnableDDR
29+
}
30+
}

CMOSErrorCode.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
namespace TianWen.DAL
2+
{
3+
public enum CMOSErrorCode
4+
{
5+
Success = 0,
6+
/// <summary>
7+
/// no camera connected or index value out of boundary
8+
/// </summary>
9+
InvalidIndex,
10+
InvalidId,
11+
InvalidControlType,
12+
/// <summary>
13+
/// Camera is not connected, or couldn't be opened
14+
/// </summary>
15+
CameraClosed,
16+
/// <summary>
17+
/// Failed to find the camera, maybe the camera has been removed
18+
/// </summary>
19+
CameraRemoved,
20+
/// <summary>
21+
/// cannot find the path of the file.
22+
/// </summary>
23+
InvalidPath,
24+
InvalidFileFormat,
25+
/// <summary>
26+
/// Wrong video format size
27+
/// </summary>
28+
InvalidSize,
29+
/// <summary>
30+
/// Unsupported image format
31+
/// </summary>
32+
InvalidImageFormat,
33+
/// <summary>
34+
/// Start position is out of boundary
35+
/// </summary>
36+
OutOfBoundary,
37+
Timeout,
38+
/// <summary>
39+
/// Stop capture first
40+
/// </summary>
41+
InvalidSequence,
42+
BufferTooSmall,
43+
VideoModeActive,
44+
ExposureInProgress,
45+
/// <summary>
46+
/// general error, eg: value is out of valid range
47+
/// </summary>
48+
GeneralError
49+
};
50+
}

INativeCMOSDeviceInfo.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,11 @@ public interface INativeCMOSDeviceInfo : INativeDeviceInfo
3939
IReadOnlyList<PixelDataFormat> SupportedPixelDataFormats { get; }
4040

4141
BayerPattern BayerPattern { get; }
42+
43+
bool TryGetControlRange(CMOSControlType ctrlType, out int min, out int max);
44+
45+
CMOSErrorCode GetControlValue(CMOSControlType controlType, out int value, out bool isAuto);
46+
47+
CMOSErrorCode SetControlValue(CMOSControlType controlType, int value, bool isAuto = false);
4248
}
4349
}

0 commit comments

Comments
 (0)