add eHDR controls
This commit is contained in:
@@ -74,6 +74,18 @@ std::string CameraController::processCommand(const std::string& jsonCommand) {
|
||||
return handleStopStream();
|
||||
} else if (command == "set_pipeline") {
|
||||
return handleSetPipeline(getParam("pipeline"));
|
||||
} else if (command == "set_ehdr_mode") {
|
||||
return handleSetEHDRMode(getParam("mode"));
|
||||
} else if (command == "set_ehdr_exposure_min") {
|
||||
return handleSetEHDRExposureMin(getParam("value"));
|
||||
} else if (command == "set_ehdr_exposure_max") {
|
||||
return handleSetEHDRExposureMax(getParam("value"));
|
||||
} else if (command == "set_ehdr_ratio_min") {
|
||||
return handleSetEHDRRatioMin(getParam("value"));
|
||||
} else if (command == "set_ehdr_ratio_max") {
|
||||
return handleSetEHDRRatioMax(getParam("value"));
|
||||
} else if (command == "get_ehdr_status") {
|
||||
return handleGetEHDRStatus();
|
||||
} else {
|
||||
return createErrorResponse("Unknown command: " + command);
|
||||
}
|
||||
@@ -233,6 +245,89 @@ std::string CameraController::handleSetGain(const std::string& value) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string CameraController::handleSetEHDRMode(const std::string& value) {
|
||||
try {
|
||||
const int mode = std::stoi(value);
|
||||
if (VxSetISPImageProcessing(camera_, VX_ISP_IMAGE_PROPERTIES::ISP_IMAGE_EHDR_MODE, mode) != 0) {
|
||||
return createErrorResponse("Failed to set eHDR mode");
|
||||
}
|
||||
return createSuccessResponse("eHDR mode set successfully");
|
||||
} catch (const std::exception& e) {
|
||||
return createErrorResponse(std::string("Invalid parameters: ") + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
std::string CameraController::handleSetEHDRExposureMin(const std::string& value) {
|
||||
try {
|
||||
const int minExp = std::stoi(value);
|
||||
if (VxSetISPImageProcessing(camera_, VX_ISP_IMAGE_PROPERTIES::ISP_EHDR_EXPOSURE_MIN_NUMBER, minExp) != 0) {
|
||||
return createErrorResponse("Failed to set eHDR exposure min");
|
||||
}
|
||||
return createSuccessResponse("eHDR exposure min set successfully");
|
||||
} catch (const std::exception& e) {
|
||||
return createErrorResponse(std::string("Invalid parameters: ") + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
std::string CameraController::handleSetEHDRExposureMax(const std::string& value) {
|
||||
try {
|
||||
const int maxExp = std::stoi(value);
|
||||
if (VxSetISPImageProcessing(camera_, VX_ISP_IMAGE_PROPERTIES::ISP_EHDR_EXPOSURE_MAX_NUMBER, maxExp) != 0) {
|
||||
return createErrorResponse("Failed to set eHDR exposure max");
|
||||
}
|
||||
return createSuccessResponse("eHDR exposure max set successfully");
|
||||
} catch (const std::exception& e) {
|
||||
return createErrorResponse(std::string("Invalid parameters: ") + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
std::string CameraController::handleSetEHDRRatioMin(const std::string& value) {
|
||||
try {
|
||||
const int minRatio = std::stoi(value);
|
||||
if (VxSetISPImageProcessing(camera_, VX_ISP_IMAGE_PROPERTIES::ISP_EHDR_RATIO_MIN, minRatio) != 0) {
|
||||
return createErrorResponse("Failed to set eHDR ratio min");
|
||||
}
|
||||
return createSuccessResponse("eHDR ratio min set successfully");
|
||||
} catch (const std::exception& e) {
|
||||
return createErrorResponse(std::string("Invalid parameters: ") + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
std::string CameraController::handleSetEHDRRatioMax(const std::string& value) {
|
||||
try {
|
||||
const int maxRatio = std::stoi(value);
|
||||
if (VxSetISPImageProcessing(camera_, VX_ISP_IMAGE_PROPERTIES::ISP_EHDR_RATIO_MAX, maxRatio) != 0) {
|
||||
return createErrorResponse("Failed to set eHDR ratio max");
|
||||
}
|
||||
return createSuccessResponse("eHDR ratio max set successfully");
|
||||
} catch (const std::exception& e) {
|
||||
return createErrorResponse(std::string("Invalid parameters: ") + e.what());
|
||||
}
|
||||
}
|
||||
|
||||
std::string CameraController::handleGetEHDRStatus() {
|
||||
int mode = 0, flag = 0;
|
||||
int expMin = 0, expMax = 0;
|
||||
int ratioMin = 0, ratioMax = 0;
|
||||
|
||||
if (VxGetISPImageProcessing(camera_, VX_ISP_IMAGE_PROPERTIES::ISP_IMAGE_EHDR_MODE, mode, flag) != 0) {
|
||||
return createErrorResponse("Failed to get eHDR mode");
|
||||
}
|
||||
|
||||
VxGetISPImageProcessing(camera_, VX_ISP_IMAGE_PROPERTIES::ISP_EHDR_EXPOSURE_MIN_NUMBER, expMin, flag);
|
||||
VxGetISPImageProcessing(camera_, VX_ISP_IMAGE_PROPERTIES::ISP_EHDR_EXPOSURE_MAX_NUMBER, expMax, flag);
|
||||
VxGetISPImageProcessing(camera_, VX_ISP_IMAGE_PROPERTIES::ISP_EHDR_RATIO_MIN, ratioMin, flag);
|
||||
VxGetISPImageProcessing(camera_, VX_ISP_IMAGE_PROPERTIES::ISP_EHDR_RATIO_MAX, ratioMax, flag);
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << "{\"status\":\"success\",\"ehdr_mode\":" << mode
|
||||
<< ",\"exposure_min\":" << expMin
|
||||
<< ",\"exposure_max\":" << expMax
|
||||
<< ",\"ratio_min\":" << ratioMin
|
||||
<< ",\"ratio_max\":" << ratioMax << "}";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
std::string CameraController::handleGetStatus() {
|
||||
std::ostringstream oss;
|
||||
oss << "{\"status\":\"success\",\"streaming\":" << (streamingEngine_->isRunning() ? "true" : "false")
|
||||
|
||||
@@ -33,6 +33,12 @@ private:
|
||||
std::string handleStartStream();
|
||||
std::string handleStopStream();
|
||||
std::string handleSetPipeline(const std::string& pipeline);
|
||||
std::string handleSetEHDRMode(const std::string& value);
|
||||
std::string handleSetEHDRExposureMin(const std::string& value);
|
||||
std::string handleSetEHDRExposureMax(const std::string& value);
|
||||
std::string handleSetEHDRRatioMin(const std::string& value);
|
||||
std::string handleSetEHDRRatioMax(const std::string& value);
|
||||
std::string handleGetEHDRStatus();
|
||||
|
||||
// Helper functions
|
||||
VX_IMAGE_FORMAT stringToFormat(const std::string& format);
|
||||
|
||||
221
SOCKET_API.md
221
SOCKET_API.md
@@ -433,6 +433,168 @@ Adjust camera gain.
|
||||
|
||||
---
|
||||
|
||||
### 15. Set eHDR Mode
|
||||
|
||||
Enable or disable eHDR (Enhanced High Dynamic Range) mode.
|
||||
|
||||
**Note:** eHDR features are only available on specific camera models: VCI-AR0821/AR0822, VCS-AR0821/AR0822, VLS3-AR0821/AR0822, VLS-GM2-AR0821/AR0822, and TEVS-AR0821/AR0822.
|
||||
|
||||
**Command:**
|
||||
```json
|
||||
{
|
||||
"command": "set_ehdr_mode",
|
||||
"params": {
|
||||
"mode": "0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `mode`: "0" to enable eHDR, "1" to disable eHDR
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"message": "eHDR mode set successfully"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 16. Set eHDR Exposure Minimum
|
||||
|
||||
Set the minimum number of exposure frames for eHDR.
|
||||
|
||||
**Command:**
|
||||
```json
|
||||
{
|
||||
"command": "set_ehdr_exposure_min",
|
||||
"params": {
|
||||
"value": "1"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `value`: Minimum exposure frames (range: 1-4, default: 1)
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"message": "eHDR exposure min set successfully"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 17. Set eHDR Exposure Maximum
|
||||
|
||||
Set the maximum number of exposure frames for eHDR.
|
||||
|
||||
**Command:**
|
||||
```json
|
||||
{
|
||||
"command": "set_ehdr_exposure_max",
|
||||
"params": {
|
||||
"value": "4"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `value`: Maximum exposure frames (range: 1-4, default: 4)
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"message": "eHDR exposure max set successfully"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 18. Set eHDR Ratio Minimum
|
||||
|
||||
Set the minimum exposure ratio for eHDR.
|
||||
|
||||
**Command:**
|
||||
```json
|
||||
{
|
||||
"command": "set_ehdr_ratio_min",
|
||||
"params": {
|
||||
"value": "12"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `value`: Minimum exposure ratio (range: 1-128, default: 12)
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"message": "eHDR ratio min set successfully"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 19. Set eHDR Ratio Maximum
|
||||
|
||||
Set the maximum exposure ratio for eHDR.
|
||||
|
||||
**Command:**
|
||||
```json
|
||||
{
|
||||
"command": "set_ehdr_ratio_max",
|
||||
"params": {
|
||||
"value": "24"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `value`: Maximum exposure ratio (range: 1-128, default: 24)
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"message": "eHDR ratio max set successfully"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 20. Get eHDR Status
|
||||
|
||||
Retrieve all current eHDR settings.
|
||||
|
||||
**Command:**
|
||||
```json
|
||||
{
|
||||
"command": "get_ehdr_status"
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"ehdr_mode": 0,
|
||||
"exposure_min": 1,
|
||||
"exposure_max": 4,
|
||||
"ratio_min": 12,
|
||||
"ratio_max": 24
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Complete Workflow Example
|
||||
@@ -448,6 +610,13 @@ echo '{"command":"set_format","params":{"width":"1920","height":"1080","framerat
|
||||
echo '{"command":"set_exposure","params":{"mode":"auto"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
echo '{"command":"set_brightness","params":{"value":"50"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
|
||||
# 3a. (Optional) Configure eHDR settings (for compatible cameras)
|
||||
echo '{"command":"set_ehdr_mode","params":{"mode":"0"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
echo '{"command":"set_ehdr_exposure_min","params":{"value":"1"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
echo '{"command":"set_ehdr_exposure_max","params":{"value":"4"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
echo '{"command":"set_ehdr_ratio_min","params":{"value":"12"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
echo '{"command":"set_ehdr_ratio_max","params":{"value":"24"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
|
||||
# 4. Start streaming
|
||||
echo '{"command":"start_stream"}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
|
||||
@@ -499,6 +668,27 @@ echo '{"command":"get_status"}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
echo '{"command":"stop_stream"}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
```
|
||||
|
||||
### eHDR Control Examples
|
||||
|
||||
```bash
|
||||
# Enable eHDR mode
|
||||
echo '{"command":"set_ehdr_mode","params":{"mode":"0"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
|
||||
# Disable eHDR mode
|
||||
echo '{"command":"set_ehdr_mode","params":{"mode":"1"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
|
||||
# Configure eHDR exposure range
|
||||
echo '{"command":"set_ehdr_exposure_min","params":{"value":"1"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
echo '{"command":"set_ehdr_exposure_max","params":{"value":"4"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
|
||||
# Configure eHDR ratio range
|
||||
echo '{"command":"set_ehdr_ratio_min","params":{"value":"12"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
echo '{"command":"set_ehdr_ratio_max","params":{"value":"24"}}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
|
||||
# Get current eHDR settings
|
||||
echo '{"command":"get_ehdr_status"}' | socat - UNIX-CONNECT:/tmp/vizion_control.sock
|
||||
```
|
||||
|
||||
### Using `nc` (netcat with Unix socket support)
|
||||
|
||||
```bash
|
||||
@@ -535,6 +725,14 @@ print(send_command("set_format", {
|
||||
}))
|
||||
print(send_command("set_exposure", {"mode": "auto"}))
|
||||
print(send_command("start_stream"))
|
||||
|
||||
# eHDR control examples (for compatible cameras)
|
||||
print(send_command("set_ehdr_mode", {"mode": "0"})) # Enable eHDR
|
||||
print(send_command("set_ehdr_exposure_min", {"value": "1"}))
|
||||
print(send_command("set_ehdr_exposure_max", {"value": "4"}))
|
||||
print(send_command("set_ehdr_ratio_min", {"value": "12"}))
|
||||
print(send_command("set_ehdr_ratio_max", {"value": "24"}))
|
||||
print(send_command("get_ehdr_status")) # Get current eHDR settings
|
||||
```
|
||||
|
||||
### Using C++
|
||||
@@ -569,6 +767,13 @@ std::string sendCommand(const std::string& command) {
|
||||
int main() {
|
||||
std::cout << sendCommand(R"({"command":"get_formats"})") << std::endl;
|
||||
std::cout << sendCommand(R"({"command":"set_brightness","params":{"value":"50"}})") << std::endl;
|
||||
|
||||
// eHDR control examples (for compatible cameras)
|
||||
std::cout << sendCommand(R"({"command":"set_ehdr_mode","params":{"mode":"0"}})") << std::endl;
|
||||
std::cout << sendCommand(R"({"command":"set_ehdr_exposure_min","params":{"value":"1"}})") << std::endl;
|
||||
std::cout << sendCommand(R"({"command":"set_ehdr_exposure_max","params":{"value":"4"}})") << std::endl;
|
||||
std::cout << sendCommand(R"({"command":"get_ehdr_status"})") << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
@@ -587,6 +792,20 @@ The valid ranges for camera parameters depend on the specific camera model. You
|
||||
- Exposure: 1-10000 (in auto mode, value is ignored)
|
||||
- White Balance Temperature: 2800-6500 Kelvin
|
||||
|
||||
**eHDR ranges (for compatible cameras only):**
|
||||
- eHDR Mode: 0 (enable) or 1 (disable)
|
||||
- eHDR Exposure Min: 1-4 (default: 1)
|
||||
- eHDR Exposure Max: 1-4 (default: 4)
|
||||
- eHDR Ratio Min: 1-128 (default: 12)
|
||||
- eHDR Ratio Max: 1-128 (default: 24)
|
||||
|
||||
**Compatible eHDR Camera Models:**
|
||||
- VCI-AR0821/AR0822
|
||||
- VCS-AR0821/AR0822
|
||||
- VLS3-AR0821/AR0822
|
||||
- VLS-GM2-AR0821/AR0822
|
||||
- TEVS-AR0821/AR0822
|
||||
|
||||
## Error Handling
|
||||
|
||||
Always check the `status` field in the response:
|
||||
@@ -661,3 +880,5 @@ curl http://192.168.1.100:8080 > stream.mjpg
|
||||
- Invalid parameter values will return an error response
|
||||
- GStreamer pipeline errors will be reported when starting the stream
|
||||
- Default pipeline: `videoconvert ! autovideosink` (display locally)
|
||||
- eHDR features require compatible camera models (VCI/VCS/VLS3/VLS-GM2/TEVS-AR0821/AR0822)
|
||||
- eHDR settings may be reset to defaults when the camera starts streaming (driver behavior)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <utility>
|
||||
|
||||
StreamingEngine::StreamingEngine(std::shared_ptr<VxCamera> camera)
|
||||
: camera_(std::move(camera)), running_(false), bufferSize_(0) {
|
||||
: camera_(std::move(camera)), running_(false), currentFormat_(), bufferSize_(0) {
|
||||
gstPipeline_ = std::make_unique<GStreamerPipeline>("");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user