Python Forum
NameError: name 'self' is not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NameError: name 'self' is not defined
#4
What will you do with the image?

The code you've posted has no imports for numpy and cv2, it's not the full code?

something like that

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
import cv2
import numpy as np

class Win():
    def __init__(self):
        window = QMainWindow()
        window.show()
 
    def getFrame(self):
        fp = r'/home/UbuntuUser/Desktop/UAV.tif'
        self.img = cv2.imdecode(np.fromfile(fp, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
        print(self.img)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    win = Win()
    win.getFrame()
    sys.exit(app.exec_())
hobbyist likes this post
Reply


Messages In This Thread
NameError: name 'self' is not defined - by hobbyist - Jan-03-2021, 05:31 PM
RE: NameError: name 'self' is not defined - by Axel_Erfurt - Jan-03-2021, 06:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Kivy] NameError: name 'App' is not defined nengkya 4 13,791 Apr-02-2017, 07:15 PM
Last Post: metulburr
  [WxPython] NameError: global name 'PyAssertionError' is not defined merlem 5 6,417 Jan-28-2017, 01:59 PM
Last Post: merlem

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020