Hi All,
I want to capture more pictures continuously but i get an error.
Source code 1:
Argus::Status ArgusCameraDriver::Capture()
{
for(uint32_t i = 0;i<300;i++)
{
iCaptureSession->capture(request, TIMEOUT_INFINITE, &status);
Frame *frame = iFrameConsumer->acquireFrame(TIMEOUT_INFINITE, &status);
IFrame *iFrame = interface_cast<IFrame>(frame);
Image *image = iFrame->getImage();
IImageJPEG *iImageJPEG = interface_cast<IImageJPEG>(image);
std::string fileName = "images/" + std::to_string(i) + ".jpg";
iImageJPEG->writeJPEG(fileName.c_str());
cout << fileName << " saved" << endl;
usleep(100000);
}
return status;
}
Output 1:
Source 2:
Argus::Status ArgusCameraDriver::Start()
{
status = iCaptureSession->repeat(request);
return status;
}
Argus::Status ArgusCameraDriver::Capture()
{
for(uint32_t i = 0;i<300;i++)
{
//iCaptureSession->capture(request, TIMEOUT_INFINITE, &status);
Frame *frame = iFrameConsumer->acquireFrame(TIMEOUT_INFINITE, &status);
IFrame *iFrame = interface_cast<IFrame>(frame);
Image *image = iFrame->getImage();
IImageJPEG *iImageJPEG = interface_cast<IImageJPEG>(image);
std::string fileName = "images/" + std::to_string(i) + ".jpg";
iImageJPEG->writeJPEG(fileName.c_str());
cout << fileName << " saved" << endl;
usleep(100000);
}
return status;
}
Argus::Status ArgusCameraDriver::Stop()
{
iCaptureSession->stopRepeat();
status = iCaptureSession->waitForIdle(TIMEOUT_INFINITE);
cameraProvider->destroy();
return status;
}
Output 2:
How can i fix it?
What do i do wrong?
br:
extsoltech
hello extsoltech,
may I know what’s your actual use-case.
since you would like to take pictures continuously, why you don’t save it as a video stream.
please refer to Multimedia API Reference, check the sample 09_camera_jpeg_capture to use libargus for saving several jpg files.
thanks
Hello JerryChang,
This is only capture test. I don’t want save the image. In the next step i want to capture an image based on trigger signal. When the signal is rising then capture. After that, i want to convert image YUV format to RGB, and work with CUDA.
So, the solution is every capture i need to destroy Frame object and evrething is working well.
There is existing any method to convert format? Or write my own use CUDA?
hello extsoltech,
there’s another MMAPI sample, 12_camera_v4l2_cuda to capture images from a V4L2 YUV type of camera and share the image stream with CUDA engines.
i ran the sample, here is the output:
and here is what i see:
i don’t know what happening, before green screen, i see black screen.
So i thinking, the sample not working.
I can set Argus more formats.
When i set any format, where can i found the format reference? So what is wich byte in array?
for example:
… //setup
iEGLOutputStreamSettings = interface_cast(outputStreamSettings);
//status = iEGLOutputStreamSettings->setPixelFormat(PIXEL_FMT_YCbCr_420_888);
status = iEGLOutputStreamSettings->setPixelFormat(PIXEL_FMT_RAW16);
status = iEGLOutputStreamSettings->setResolution(iSensorMode->getResolution());
status = iEGLOutputStreamSettings->setMetadataEnable(true);
…
.. //capture
Frame *frame = iFrameConsumer->acquireFrame();
IFrame *iFrame = interface_cast<type>(frame);
Image *image = iFrame->getImage();
IImage *iImage = interface_cast<IImage>(image);
uint32_t bufferCount = iImage->getBufferCount();
for(uint32_t i=0;i<bufferCount;i++)
{
cout << "buffer " << i << " size:" << iImage->getBufferSize(i) << endl;
}
..
output:
So i have 16515072 bytes in buffer. What is this values in RAW16 format?
…
Frame *frame = iFrameConsumer->acquireFrame();
IFrame *iFrame = interface_cast
Size2D<uint32_t> resolution = iImage2D->getSize();
cout << "resolution: " << resolution.width() << 'x' << resolution.height() << endl;
uint32_t bufferCount = iImage->getBufferCount();
for(uint32_t i=0;i<bufferCount;i++)
{
uint64_t bufferSize = iImage->getBufferSize(i);
uint32_t stride = iImage2D->getStride();
cout << "buffer " << i << " size:" << bufferSize << " byte(s)" << endl;
cout << "stride: " << stride << " byte(s)" << endl;
cout << "calculated image width: " << stride /2 << " px" << endl;
cout << "calculated image height: " << bufferSize / stride << " px" << endl;
}
…
the calculated values are not match with the resolution:
why not matching?
hello extsoltech,
I’m not sure which sensor module you’re using,
please enable v4l2-ctl to parse all supported sensor modes and its default pixel formats.
for example,
$ v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'BG10'
Name : 10-bit Bayer BGBG/GRGR
Size: Discrete 2592x1944
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 2592x1458
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.008s (120.000 fps)
v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'RG10'
Name : 10-bit Bayer RGRG/GBGB
Size: Discrete 3264x2464
Interval: Discrete 0.048s (21.000 fps)
Size: Discrete 3264x1848
Interval: Discrete 0.036s (28.000 fps)
Size: Discrete 1920x1080
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.017s (60.000 fps)
hello extsoltech,
it’s a 10-bit RGGB bayer sensor, you cannot enable 12_camera_v4l2_cuda MMAPI sample since it request for YUV input formats.
please refer to 09_camera_jpeg_capture for demonstration.
thanks
Yes, the 09_camera_jpeg_capture is working well.
The NvBuffer is shared memory? Wich example show for me how to access the NvBuffer from CUDA?
hello extsoltech,
you may refer to Argus samples, you may found the sources if you’d install the multimedia components.
for example,
/usr/src/jetson_multimedia_api/argus/samples/*
here’s cudaHistogram sample, which creates an EGLStream and performs a series of captures, with a consumer that uses CUDA to calculate and print 64-bin histograms for each frame.
please also check the readme file for the guidance to compile the sources.
for example,
/usr/src/jetson_multimedia_api/argus/README.TXT