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 44.6k 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
    #13

    You're using it as if it were a static method which it's not. You need an instance of QScreen.

    You can get one from your QApplication.

    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're using it as if it were a static method which it's not. You need an instance of QScreen.

      You can get one from your QApplication.

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

      @SGaist Sorry I do not understand...how I get an instance from QApplication in QScreen?

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

        It's the other way around.

        In any case, you should rather get the screen from your widget.

        Take a look at the screenshot example.

        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
        2
        • J Offline
          J Offline
          john_hobbyist
          wrote on last edited by john_hobbyist
          #16

          @SGaist

          I just try to see how to run the QRubberBand in PyQt5....

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

            Did you check the example from the 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 john_hobbyist
              #18

              I added them to the main class. I am trying to call the methods, like this:

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

              etc.

              But what do I put inside/instead of "event"?

              mrjjM 1 Reply Last reply
              0
              • J john_hobbyist

                I added them to the main class. I am trying to call the methods, like this:

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

                etc.

                But what do I put inside/instead of "event"?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #19

                @john_hobbyist

                The code you showed higher up to drive the rubber band.
                Or the docs @SGaist points to. they explain in detail what is needed.

                def mousePressEvent(self, event):   ///// this set the start location of the band
                    self.origin = event.pos()
                    self.rubberband.setGeometry(
                        QtCore.QRect(self.origin, QtCore.QSize()))
                    self.rubberband.show()
                    QtGui.QWidget.mousePressEvent(self, event)
                
                def mouseMoveEvent(self, event): // this makes the band follow the mouse to adjust the size
                    if self.rubberband.isVisible():
                        self.rubberband.setGeometry(
                            QtCore.QRect(self.origin, event.pos()).normalized())
                    QtGui.QWidget.mouseMoveEvent(self, event)
                
                def mouseReleaseEvent(self, event): // this is the end of the operation and you use the rectange defined by the band
                    if self.rubberband.isVisible():
                        self.rubberband.hide()
                   rect = self.rubberband.geometry()
                
                 ... then use rect for whatever you need
                
                1 Reply Last reply
                2
                • J Offline
                  J Offline
                  john_hobbyist
                  wrote on last edited by john_hobbyist
                  #20

                  @mrjj: Thanks for your help! I am searching all morning. Here https://doc.qt.io/qtforpython/PySide6/QtWidgets/QRubberBand.html#more I don't see something about what to put inside the "event". The only I can understand is to use this inside events: https://doc.qt.io/qtforpython-5/PySide2/QtGui/QMouseEvent.html

                  mrjjM 1 Reply Last reply
                  0
                  • J john_hobbyist

                    @mrjj: Thanks for your help! I am searching all morning. Here https://doc.qt.io/qtforpython/PySide6/QtWidgets/QRubberBand.html#more I don't see something about what to put inside the "event". The only I can understand is to use this inside events: https://doc.qt.io/qtforpython-5/PySide2/QtGui/QMouseEvent.html

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #21

                    @john_hobbyist

                    Im not sure what you refer too ?

                    def mouseReleaseEvent(self, event): <<< this event ? the paramter ?

                    To use the rubberband, we use 3 functions as shown.

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

                      @mrjj
                      Yes, I try this:

                      self.mousePressEvent(event)
                      

                      and the code requires to put something instead of "event". This is the error:

                      File "code.py", line 310, in __init__
                        self.mousePressEvent(event)
                      NameError: name 'event' is not defined
                      
                      1 Reply Last reply
                      0
                      • 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

                                          • Login

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