is it possible to use QtConcurrent::mapped inside a QThread ?
-
Hi,
I want to process my my opencv captured frames in 4 threads.
one producer (opencv capture ) is very fast
four worker (detection cpu based) slower than producer (4 times almost)
I created producer thread and moved a thread.
1 - Can I create a QtConcurred::mapped in this producer Thread ?
what is the best practices for this multithreaded video processing in Qt ?
-
Hi,
AFAIK, yes you can.
You have to benchmark the processings you need before designing a pipeline for your video application.
-
I have below error:
struct frames_facePhotos { cv::Mat frames; cv::Mat face_photo; }; QVector<frames_facePhotos> framesVector;
frames_facePhotos process_request; process_request.face_photo = face_photo; process_request.frames = image; framesVector.push_back (process_request); cap>>image; process_request.frames = image; framesVector.push_back (process_request); auto res = QtConcurrent::mapped(framesVector , &detecFaceModifyFrames );
void FaceDetector::detecFaceModifyFrames(frames_facePhotos frames_faces) { int frame_count = 111; QString find_face = bc_face->findFace(frames_faces.frames, frames_faces.face_photo,frame_count); // return frames_faces; }
- Error
../BC_DETECTOR/face_detector.cpp:165:60: error: must explicitly qualify name of member function when taking its address
auto res = QtConcurrent::mapped(framesVector , &detecFaceModifyFrames );
^~~~~~~~~~~~~~~~~~~~~~
FaceDetector::
2nd Error
/Users/xx/Qt5.12.1/5.12.1/clang_64/lib/QtConcurrent.framework/Headers/qtconcurrentmapkernel.h:175:19: error: no matching function for call to object of type 'QtConcurrent::MemberFunctionWrapper1<void, FaceDetector, FaceDetector::frames_facePhotos>'
*result = map(*it);
^~~when I change to :
auto res = QtConcurrent::mapped(framesVector , &FaceDetector::detecFaceModifyFrames );
first error gone but second is there.
- Error
-
@RahibeMeryem Try to use lambda instead of detecFaceModifyFrames. detecFaceModifyFrames is a non static method and cannot be used without class instance.
-
when I think that I started to capture C++ something like this happening. as a being decent java girl its make me crazy :)
how can I write its as a lamba ?
-
auto res = QtConcurrent::mapped(framesVector , [this](frames_facePhotos frames_faces) { detecFaceModifyFrames(frame_faces); });