Hello,
i use libcamera and all works so far correct, now i will extend my callback methode for each frame, and i will transfer an this pointer from my baseclass
i start also my camera with :
And have transmit my this pointer all works so far, but in the callback routine , how i can become back my this ptr ?
Atm in this version i use an global ptr, but i will install two cams, and cant use an global ptr:
Code
void CCamSrv::RequestCompleted(libcamera::Request* request)//wtf without *userdata
{
if (request->status() == libcamera::Request::RequestCancelled || !g_pHost->m_bIsRunning)
{
// vcos_semaphore_post(&g_pHost->m_semaframe);
return;
}
//CCamSrv *pCam = (CCamSrv * ) libcamera::BoundMethodMember;
vcos_mutex_lock(&g_pHost->m_FrameLatch);
const libcamera::Request::BufferMap &buffers = request->buffers();
for (libcamera::Request::BufferMap::const_iterator it = buffers.begin(); it != buffers.end(); it++)
{
libcamera::FrameBuffer* buffer = (*it).second;
const libcamera::FrameMetadata& metadata = buffer->metadata(); //metadata.sequence; metadata.timestamp;
/*
const libcamera::ControlList& requestMetadata = request->metadata();
for (const auto& ctrl : requestMetadata)
{
const libcamera::ControlId* id = libcamera::controls::controls.at(ctrl.first);
const libcamera::ControlValue& value = ctrl.second;
std::cout << "\t" << id->name() << " = " << value.toString() << std::endl;
}*/
g_pHost->m_Fps = (metadata.timestamp - g_pHost->m_LstTi) / 1000000.0f;
g_pHost->m_LstTi = metadata.timestamp; //printf("ti=%0.1f\n", g_pHost->m_Fps);
unsigned int nplane(0); //metadata.timestamp
for (const libcamera::FrameMetadata::Plane &plane : metadata.planes())//after control its calling once only
memcpy((g_pHost->m_pMem[((g_pHost->m_PicNr + 1) % NUMBUFFS)] + sizeof(BITMAPFILEHEADER)) + sizeof(BITMAPINFOHEADER), g_pHost->m_MapBuffMem.find(buffer)->second, metadata.planes()[nplane++].bytesused);
}
g_pHost->m_PicNr++;
/*
int idx((g_pHost->m_PicNr) % NUMBUFFS);
unsigned long sz(g_pHost->m_BmpFileHdr.bfSize);
g_pHost->JpgDecoder((g_pHost->m_pMem[idx] + sizeof(BITMAPFILEHEADER)) + sizeof(BITMAPINFOHEADER), g_pHost->m_Width, g_pHost->m_Height, g_pHost->m_pMemOut[idx], &sz);//decode to jpg image
g_pHost->m_SzMem[idx] = sz;
*/
vcos_mutex_unlock(&g_pHost->m_FrameLatch);
request->reuse(libcamera::Request::ReuseBuffers);
if (g_pHost->m_bParamChg)
{
g_pHost->m_bParamChg = false;
libcamera::ControlList& controls(request->controls());
controls.set<float>(libcamera::controls::Saturation, g_pHost->m_fSaturation);
controls.set<float>(libcamera::controls::Brightness, g_pHost->m_fBrightness);
controls.set<float>(libcamera::controls::Contrast, g_pHost->m_fContrast);
controls.set<float>(libcamera::controls::Sharpness, g_pHost->m_fSharpness);
controls.set<float>(libcamera::controls::ExposureValue, g_pHost->m_fExposureV);
controls.set<int32_t>(libcamera::controls::ExposureTime, g_pHost->m_ExposureT);
controls.set<float>(libcamera::controls::AnalogueGain, g_pHost->m_fGain);
/*
std::int64_t value_pair[2] = { g_pHost->m_Duration / 2, 0 };
controls.set(libcamera::controls::FrameDurationLimits, libcamera::Span<const std::int64_t, 2>(value_pair));
*/
//hmm reduce flashing images on lightsource change
controls.set(libcamera::controls::AeEnable, 0);
controls.set(libcamera::controls::AwbEnable, libcamera::controls::AwbModeEnum::AwbFluorescent);
controls.set<int32_t>(libcamera::controls::AeExposureMode, libcamera::controls::AeExposureModeEnum::ExposureShort);
controls.set(libcamera::controls::AeMeteringMode, libcamera::controls::AeConstraintModeEnum::ConstraintNormal);
}
g_pHost->m_Camera->queueRequest(request);
}
Display More
have amy one an idea to become my this ptr in the callback ?
Thanks so much for any Help
regards karsten.