0

My requirement is to create a window in which I have a square frame. And I need to play the video inside this square frame.

I think I can solve my requirement if I can correctly run the code here: How to display a cv2 video inside a python GUI?.

As I am new to Python coding, I am facing some issues...

Traceback (most recent call last):
  File "exp2.py", line 10, in <module>
    img = QImage(frame, frame.shape[1], frame.shape[0], QImage.Format_RGB888)
NameError: name 'QImage' is not defined

please help!

user78910
  • 349
  • 2
  • 12
  • You are missing imports. In general it might be a good idea to learn the language you are trying to program in. – Klaus D. May 14 '20 at 08:11

2 Answers2

1

You should import QImage at the beggining of the program.

from PyQt4.QtGui import QImage
Mahsa
  • 732
  • 5
  • 13
0

To do this you need to get each individual frame of a video, and insert that frame inside of the image:

frame.copyTo(img(cv2.Rect(x,y,frame.cols, frame.rows)))

This will put the frame inside of img starting at x,y ending at frame.cols, frame.rows

Dimitar
  • 1,148
  • 8
  • 29