Solved Intel RealSense ID Face recognition callback
-
Hi all,
I'm playing with the Intel Real Sense ID SDK for face recognition.
https://www.intelrealsense.com/facial-authentication/I'm trying to integrate in a QT widget application but when I have to call the authentication procedure I have to pass a "callback class" like this:
RealSenseID::FaceAuthenticator authenticator; auto status = authenticator.Connect({"COM9"}); if (status == RealSenseID::Status::Ok) { MyAuthClbk auth_clbk; authenticator.Authenticate(auth_clbk); // <-- I HAVE TO PASS THE CALLBACK }
and this is the callback class
class MyAuthClbk : public RealSenseID::AuthenticationCallback { public: void OnResult(const RealSenseID::AuthenticateStatus status, const char* user_id) override { if (status == RealSenseID::AuthenticateStatus::Success) std::cout << "Authenticated " << user_id << std::endl; } void OnHint(const RealSenseID::AuthenticateStatus hint) override { std::cout << "OnHint " << hint << std::endl; } void OnFaceDetected(const std::vector<RealSenseID::FaceRect>& faces, const unsigned int ts) override { for (auto& face : faces) { printf("** Detected face %u,%u %ux%u (timestamp %u)\n", face.x, face.y, face.w, face.h, ts); } } };
When the callback is invoked how do I call my QT object or window by signal?
Eg. instead the linestd::cout << "Authenticated " << user_id << std::endl;
I want to call a signal with a QString of the user id
Thank you for any suggestion... -
@addebito said in Intel RealSense ID Face recognition callback:
When the callback is invoked how do I call my QT object or window by signal?
I want to call a signal with a QString of the user id
I don't really understand what you are asking for, perhaps someone else will do so better. But if it helps: you "raise"/"call" a signal in Qt via
emit
, likeemit someSignal(something)
orsomeObject->emit(something)
. You can only pass, say, aQString
as a parameter if the signal has been defined to take that parameter. You cannot change the inbuilt Qt signals' parameters to something they don't expect, just because you feel like doing so. But you can write your own signals if you wish. -
C++ allows multiple inheritance:
class MyAuthClbk : public QObject, public RealSenseID::AuthenticationCallback
Now you can define and emit signals from the callback class (don't forget the
Q_OBJECT
macro) -