How to plot a graph when terminating a computer vision script on Raspberry pi?

Asked

Viewed 242 times

0

I have a code using opencv Raspberry Pi and it is running a pattern recognition loop. In the end I close the script using "Ctrl + X" without any problem! I want to "stop" the graphical processing, perform a function to plot a graph of the recognition information such as position, size and other parameters.

How can I do that?

In the example code I put the function call when it stops. but I was unsuccessful. Function name is "Report_moves

while True:

// outras funções de reconhecimento, loop do processamento

if cv.WaitKey(10) == 27:
 break
Relatorio_Movimentos(Parado, Aj_Sup, Aj_Inf, Dir, Esq, Frt, Trs)
cv.DestroyAllWindows()  
gpio.cleanup()  
  • Try adding a cv::waitKey(0); after the function that generates the report and before destroying the windows. Maybe the report is running properly but the program closes before you can see the result...

  • Create the Motion_report in a thread. And keep the original application waiting for the breakpoint. If it happens, kill the thread.

1 answer

2

// Se o usuário pressionar a tecla ESC
if cv.WaitKey(10) == 27:
    // Exibir o relatório
    Relatorio_Movimentos(Parado, Aj_Sup, Aj_Inf, Dir, Esq, Frt, Trs)

    // Observe que se a função acima exibir uma janela do OpenCV, você deve invocar:
    //cv.WaitKey(0)
    break

Browser other questions tagged

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