Opencv c ++ how to display a text (letter) on the webcam in c++?

Asked

Viewed 122 times

0

I’m using, open source, sorry, I’m beginner, I want to change it on if and else:

 else if (!thumbIsOpen && !firstFingerIsOpen && !secondFingerIsOpen && !thirdFingerIsOpen && !fourthFingerIsOpen)
    {
        LOG(INFO) << "FIST!";
    }

instead of log, I want to show the word on webcam how to do this in C++?

or any tips on how to fix Python with C++...

Thank you!

1 answer

1


So describing succinctly, without treating the possibility of failure, as empty frame or the camera has not been opened, together with the answer to the question, we have:

// Inicializa a camera
VideoCapture camera;

for(;;)
{

    Mat frame;

    // Passa o frame capturado para a variável
    camera >> frame;

    // Escrevendo em vermelho "Texto na Imagem", no frame a cada novo frame
    cv2.putText(frame, "Texto na Imagem", (0, 100), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255));

    // Exibe a imagem com o texto
    cv2.imshow("Nome da Janela de Exibicao", frame);

    // Para a execução ao pressionar ESC
    if(waitKey(10) == 27)
    {
        break;
    }

}
  • You asked what it was like in C++

  • If you want to amend C with Python, you should search for Cython, besides that the code I made is practically the same for Python, only changes the variable.

  • Ok, is that "cv2.putText" is in python I think, I will try to study the cython and implement in the project, thank you very much for clarifying my doubts!

  • putText is from Opencv, so it works for Python and C++

  • I understood sorry for my error I searched and really putText serves for both, I’m only doing wrong in the code while running it have kind an error what is "putText" not declared...

  • Check out the Miles

  • #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> #include <string> am using these.

  • Try using something to print the opencv version, to see if it really matters

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.