libargus调整ISP详细代码
时间: 2024-01-30 16:02:59 浏览: 226
以下是使用libargus调整ISP参数的示例代码:
```c++
#include <Argus/Argus.h>
#include <EGLStream/EGLStream.h>
#include <unistd.h>
using namespace Argus;
using namespace EGLStream;
int main(int argc, char** argv)
{
// 创建CaptureSession
UniqueObj<CameraProvider> cameraProvider(CameraProvider::create());
ICameraProvider* iCameraProvider = interface_cast<ICameraProvider>(cameraProvider);
if (!iCameraProvider)
{
printf("Failed to create CameraProvider.\n");
return -1;
}
std::vector<CameraDevice*> cameraDevices;
if (iCameraProvider->getCameraDevices(&cameraDevices) != STATUS_OK)
{
printf("Failed to get CameraDevices.\n");
return -1;
}
CameraDevice* cameraDevice = cameraDevices[0];
UniqueObj<CaptureSession> captureSession(iCameraProvider->createCaptureSession(cameraDevice));
ICaptureSession* iCaptureSession = interface_cast<ICaptureSession>(captureSession);
if (!iCaptureSession)
{
printf("Failed to create CaptureSession.\n");
return -1;
}
// 设置输出流
UniqueObj<OutputStreamSettings> streamSettings(iCaptureSession->createOutputStreamSettings(STREAM_TYPE_EGL));
IEGLStreamSettings* iEGLStreamSettings = interface_cast<IEGLStreamSettings>(streamSettings);
if (!iEGLStreamSettings)
{
printf("Failed to create OutputStreamSettings.\n");
return -1;
}
iEGLStreamSettings->setPixelFormat(PIXEL_FMT_YCbCr_420_888);
iEGLStreamSettings->setResolution(Size2D<uint32_t>(1920, 1080)); // 设置分辨率
iEGLStreamSettings->setBufferCount(4);
UniqueObj<OutputStream> outputStream(iCaptureSession->createOutputStream(streamSettings.get()));
IEGLOutputStream* iEGLOutputStream = interface_cast<IEGLOutputStream>(outputStream);
if (!iEGLOutputStream)
{
printf("Failed to create OutputStream.\n");
return -1;
}
// 创建请求
UniqueObj<Request> request(iCaptureSession->createRequest(CAPTURE_INTENT_PREVIEW));
IRequest* iRequest = interface_cast<IRequest>(request);
if (!iRequest)
{
printf("Failed to create Request.\n");
return -1;
}
ISourceSettings* iSourceSettings = interface_cast<ISourceSettings>(iRequest->getSourceSettings());
if (!iSourceSettings)
{
printf("Failed to get SourceSettings.\n");
return -1;
}
iSourceSettings->setSensorMode(0); // 设置相机传感器模式
// 调整ISP参数
IAutoControlSettings* iAutoControlSettings = interface_cast<IAutoControlSettings>(iRequest->getAutoControlSettings());
if (!iAutoControlSettings)
{
printf("Failed to get AutoControlSettings.\n");
return -1;
}
iAutoControlSettings->setAeTargetFpsRange(Range<float>(30.0f, 30.0f)); // 设置帧率
iAutoControlSettings->setAeAntibandingMode(ANTIBANDING_MODE_AUTO); // 设置抗闪烁模式
iAutoControlSettings->setAeLock(true); // 锁定自动曝光
// 开始捕获
iCaptureSession->repeat(request.get());
usleep(5000000); // 等待5秒钟
iCaptureSession->stopRepeat();
return 0;
}
```
这段代码演示了如何使用libargus调整ISP参数,包括设置分辨率、帧率、抗闪烁模式等。注意,在设置自动曝光时需要先将自动曝光锁定,否则设置不会生效。
阅读全文