I wanted to tweak the syncsensor example provided in the Tegra Multimedia for my use case.
Use Case
- Synchronization of four cameras
- 4 Jpeg Consumer or 4 OpenCV Consumer - Image capture from four cameras based on a trigger from GPIO.
- Detail:Four cameras should be opened all the time and a single image from all the cameras should be captured based on a trigger from GPIO. The camera should be opened all the time and should wait for a trigger to capture.
From my understanding, I think, the images can be pulled from this thread attached below. But I don’t know how to go about it.
bool StereoDisparityConsumerThread::threadExecute()
{
CONSUMER_PRINT("Waiting for Argus producer to connect to left stream.\n");
m_leftStream->waitUntilConnected();
CONSUMER_PRINT("Waiting for Argus producer to connect to right stream.\n");
m_rightStream->waitUntilConnected();
CONSUMER_PRINT("Streams connected, processing frames.\n");
unsigned int histogramLeft[HISTOGRAM_BINS];
unsigned int histogramRight[HISTOGRAM_BINS];
while (true)
{
EGLint streamState = EGL_STREAM_STATE_CONNECTING_KHR;
// Check both the streams and proceed only if they are not in DISCONNECTED state.
if (!eglQueryStreamKHR(m_leftStream->getEGLDisplay(),m_leftStream->getEGLStream(),EGL_STREAM_STATE_KHR,&streamState) || (streamState == EGL_STREAM_STATE_DISCONNECTED_KHR))
{
CONSUMER_PRINT("left : EGL_STREAM_STATE_DISCONNECTED_KHR received\n");
break;
}
if (!eglQueryStreamKHR(m_rightStream->getEGLDisplay(),m_rightStream->getEGLStream(),EGL_STREAM_STATE_KHR,&streamState) || (streamState == EGL_STREAM_STATE_DISCONNECTED_KHR))
{
CONSUMER_PRINT("right : EGL_STREAM_STATE_DISCONNECTED_KHR received\n");
break;
}
ScopedCudaEGLStreamFrameAcquire left(m_cuStreamLeft);
ScopedCudaEGLStreamFrameAcquire right(m_cuStreamRight);
if (!left.hasValidFrame() || !right.hasValidFrame())
break;
// Calculate histograms.
float time = 0.0f;
if (left.generateHistogram(histogramLeft, &time) && right.generateHistogram(histogramRight, &time))
{
// Calculate KL distance.
float distance = 0.0f;
Size2D<uint32_t> size = right.getSize();
float dTime = computeKLDistance(histogramRight,histogramLeft,HISTOGRAM_BINS,size.width() * size.height(),&distance);
CONSUMER_PRINT("KL distance of %6.3f with %5.2f ms computing histograms and " "%5.2f ms spent computing distance\n",distance, time, dTime);
}
}
CONSUMER_PRINT("No more frames. Cleaning up.\n");
PROPAGATE_ERROR(requestShutdown());
return true;
}
I want the consumer to be JPEG or OpenCV.
- Is it possible to grab the synced image in opencv or Jpeg consumer? If possible, can anyone give a snippet?
- Is it possible to push images from CUDA to OpenCV from the above thread? Please guide me in the right direction with a piece of code
Thanks