Hi,
I'm building a super 8 film scanner. The processing involves taking several thousand images - one of each frame. While it is crucial that the frame does not move while it is being imaged, I want it to take as little time as possible so that the whole process progresses as quickly as possible.
I've been trying to set up a Fence to block the main thread until the image is saved. I got the code working using std::this_thread::sleep_for(std::chrono::milliseconds(3000)); prior to adding the fence.
The fence setup code I've been using is:
and when the image has been captured:
The issue is that bufferFence returned by releaseFence is always nullptr.
Is this at least close to what is needed? I have no idea because there does not seem to be a single application on github that uses a fence. Has anyone got a fence to work?
nick
I'm building a super 8 film scanner. The processing involves taking several thousand images - one of each frame. While it is crucial that the frame does not move while it is being imaged, I want it to take as little time as possible so that the whole process progresses as quickly as possible.
I've been trying to set up a Fence to block the main thread until the image is saved. I got the code working using std::this_thread::sleep_for(std::chrono::milliseconds(3000)); prior to adding the fence.
The fence setup code I've been using is:
Code:
main(){/// setup setup - works fine// get a real file descriptor from a real file int _fd = open(filename.c_str(), O_WRONLY | O_TRUNC | O_CREAT ); // returns an int != -1// build the Fence UniqueFD fd(_fd); std::unique_ptr<libcamera::Fence> fenceCapture = std::make_unique<libcamera::Fence>(std::forward<UniqueFD>(fd)); std::unique_ptr<Request> requestCapture = camera->createRequest(); if (!requestCapture) { std::cerr << "Can't create capture request" << std::endl; return -ENOMEM; }// pass the fence into the request with the buffer ret = requestCapture->addBuffer(streamCapture, buffersCapture[0].get(), std::move(fenceCapture));/// queue requests etc. etc. }Code:
static void requestComplete(Request *request){// ... for (auto bufferIterator = std::begin(buffers); bufferIterator != std::end(buffers); bufferIterator++) {// everything good and the file saves without any problem png_save(it->second, info, filename);// retrieve the Fence std::unique_ptr<Fence> bufferFence = bufferIterator->second->releaseFence(); if (bufferFence == nullptr)//<-- always true { std::cout << "the buffer fence is null" << std::endl; return; } if (bufferFence->isValid())// <-- segmentation fault if executed bufferFence->release(); else std::cout << "Fence is no longer valid" << std::endl; }// ...}Is this at least close to what is needed? I have no idea because there does not seem to be a single application on github that uses a fence. Has anyone got a fence to work?
nick
Statistics: Posted by nickoppen — Wed Aug 14, 2024 11:49 am — Replies 0 — Views 26