Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Matching 2 .tiff images pixel-by-pixel
Qt 6.12 LTS is out! See what's new in the release blog

Matching 2 .tiff images pixel-by-pixel

Scheduled Pinned Locked Moved Solved General and Desktop
55 Posts 5 Posters 43.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #23

    Where are you calling these methods from ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    1
    • J Offline
      J Offline
      john_hobbyist
      wrote on last edited by john_hobbyist
      #24

      @SGaist : Inside this method:

      def __init__(self, parent=None):
         . . . 
         (code)
         . . . 
         self.mousePressEvent(event)
         self.mouseMoveEvent(event)
         self.mouseReleaseEvent(event)
      
      . . . 
      
      (other methods + code per method)
      
      . . . 
      
      def mousePressEvent(self, event):
         (code)
      
      def mouseMoveEvent(self, event):
         (code)
      
      def mouseReleaseEvent(self,event):
         (code)
         
      

      which the first method of the class. Any idea?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #25

        That's not how it works. These methods are automatically called when appropriate.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        J 1 Reply Last reply
        1
        • SGaistS SGaist

          That's not how it works. These methods are automatically called when appropriate.

          J Offline
          J Offline
          john_hobbyist
          wrote on last edited by john_hobbyist
          #26

          @SGaist : So I remove these lines?

          self.mousePressEvent(event)
          self.mouseMoveEvent(event)
          self.mouseReleaseEvent(event)
          

          What should I change?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #27

            Implement the methods like shown in the QRubberBand class documentation.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • J Offline
              J Offline
              john_hobbyist
              wrote on last edited by
              #28

              @SGaist: Ok, I followed this: https://doc.qt.io/qtforpython/PySide6/QtWidgets/QRubberBand.html#qrubberband I put them into the Class. And that's it?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #29

                That's the base yes.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • J Offline
                  J Offline
                  john_hobbyist
                  wrote on last edited by john_hobbyist
                  #30

                  @SGaist: It seems to get response, although I do not see the red rectangle... But the mouse events seem to recognize when I press or when I release the mouse. But I need to install rubberband because I get this error:

                  File "code.py", line 174, in mouseMoveEvent
                    rubberBand.setGeometry(QRect(origin, event.pos()).normalized())
                  NameError: name 'rubberBand' is not defined
                  

                  I am trying to fix it though! THANX!!!

                  jsulmJ 1 Reply Last reply
                  0
                  • J john_hobbyist

                    @SGaist: It seems to get response, although I do not see the red rectangle... But the mouse events seem to recognize when I press or when I release the mouse. But I need to install rubberband because I get this error:

                    File "code.py", line 174, in mouseMoveEvent
                      rubberBand.setGeometry(QRect(origin, event.pos()).normalized())
                    NameError: name 'rubberBand' is not defined
                    

                    I am trying to fix it though! THANX!!!

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #31

                    @john_hobbyist said in Matching 2 .tiff images pixel-by-pixel:

                    NameError: name 'rubberBand' is not defined

                    So, did you define rubberBand?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    1
                    • J Offline
                      J Offline
                      john_hobbyist
                      wrote on last edited by john_hobbyist
                      #32

                      @jsulm: I try this solution from here: https://stackoverflow.com/questions/59899103/python-3-6-how-to-install-rubberband I haven't found a working solution but I am trying, because it has many! Any other idea?

                      jsulmJ 1 Reply Last reply
                      0
                      • J john_hobbyist

                        @jsulm: I try this solution from here: https://stackoverflow.com/questions/59899103/python-3-6-how-to-install-rubberband I haven't found a working solution but I am trying, because it has many! Any other idea?

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #33

                        @john_hobbyist You did not answer the question...
                        The error you get says that rubberBand was not defined. It has nothing to do with installing anything.

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          john_hobbyist
                          wrote on last edited by
                          #34

                          @jsulm: I added this:

                          import rubberband
                          

                          but again does not work! What should I do?

                          jsulmJ 1 Reply Last reply
                          0
                          • J john_hobbyist

                            @jsulm: I added this:

                            import rubberband
                            

                            but again does not work! What should I do?

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #35

                            @john_hobbyist Please read more carefully! Nobody is talking about "rubberband"!
                            The question was about: "NameError: name 'rubberBand' is not defined"
                            rubberband != rubberBand
                            So, one more time I repeat the question: was rubberBand defined anywhere?

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            1
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #36

                              There are some errors in the python document snippet that will be fixed.

                              Here's an example:

                              import sys
                              
                              from PySide2.QtCore import QRect
                              from PySide2.QtCore import QSize
                              from PySide2.QtWidgets import QWidget
                              from PySide2.QtWidgets import QRubberBand
                              from PySide2.QtWidgets import QApplication
                              
                              class Widget(QWidget):
                                  def __init__(self, parent=None):
                                      super().__init__(parent)
                              
                                      self.rubberBand = None
                                      self.origin = None
                              
                                  def mousePressEvent(self, event):
                                      self.origin = event.pos()
                                      if not self.rubberBand:
                                          self.rubberBand = QRubberBand(QRubberBand.Rectangle, self)
                                      self.rubberBand.setGeometry(QRect(self.origin, QSize()))
                                      self.rubberBand.show()
                              
                                  def mouseMoveEvent(self, event):
                                      self.rubberBand.setGeometry(QRect(self.origin, event.pos()).normalized())
                              
                                  def mouseReleaseEvent(self, event):
                                      self.rubberBand.hide()
                                      # determine selection, for example using QRect.intersects()
                                      # and QRect.contains().
                              
                              if __name__ == "__main__":
                                  app = QApplication(sys.argv)
                                  widget = Widget()
                                  widget.show()
                                  sys.exit(app.exec_())
                              

                              On a side note, it looks like you are a beginner with Python, I would recommend getting the basics first before going further.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              J 1 Reply Last reply
                              3
                              • J Offline
                                J Offline
                                john_hobbyist
                                wrote on last edited by
                                #37

                                @jsulm : No

                                @SGaist: Thanks, I am looking at it...

                                1 Reply Last reply
                                0
                                • J Offline
                                  J Offline
                                  john_hobbyist
                                  wrote on last edited by john_hobbyist
                                  #38

                                  @SGaist: I installed PySide2 and your code runs perfectly! Many thanks!

                                  I combined your above code with my code and tried to run it, but I get this error:

                                  File "code.py", line 30, in <module>
                                    from PySide2.QtCore import QRect
                                  ImportError: /lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.15' not found (required by /home/john/.local/lib/python3.8/site-packages/PySide2/QtCore.abi3.so)
                                  

                                  After google search I found and followed the suggestions from this tutorial: https://stackoverflow.com/questions/63903441/python3-importerror-lib-x86-64-linux-gnu-libqt5core-so-5-version-qt-5-15-n which does not help because it is related to PyQt5 and not PySide2.

                                  I have to note at this point that in my code I use both PyQt5 and PySide2 packages. Could the above error be a result of conflict between the packages?

                                  I also study this: https://forum.qt.io/topic/89263/qt5-pyqt5-and-opencv-problem-with-import

                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #39

                                    How did you install them both ?
                                    Did you do that in the same environment ?

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    1
                                    • J Offline
                                      J Offline
                                      john_hobbyist
                                      wrote on last edited by
                                      #40

                                      @SGaist : Yes I did that on the same environment.

                                      I tried this:

                                      sudo apt-get install python3-pyqt5.qtwebengine
                                      

                                      and this:

                                      sudo apt-get install python3-pyqt5
                                      
                                      1 Reply Last reply
                                      0
                                      • SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #41

                                        You did not install PySide2 in the same manner.

                                        Interested in AI ? www.idiap.ch
                                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        J 1 Reply Last reply
                                        1
                                        • SGaistS SGaist

                                          You did not install PySide2 in the same manner.

                                          J Offline
                                          J Offline
                                          john_hobbyist
                                          wrote on last edited by
                                          #42

                                          @SGaist : Yes.

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt
                                          • Unsolved