Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Attaching image to camera calibrator adds offset to camera

    Cinema 4D SDK
    python r19
    3
    10
    1.5k
    Loading More Posts
    • 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.
    • A
      AndreAnjos
      last edited by m_adam

      Hi all,

      I'm having a strange bug with the camera calibrator that hopefully you may be aware of.

      I create the camera, the camera calibrator tag and add an image. The Offset Y of the changes to a value, even though the Camera calibrator Image Offset Y is at 0%.
      Once I manually force update the Image Offset Y to 0% it reverts the camera Offset Y.

      alt text

      Thank you in advance! ☺

      Andre

      P.S. Apologies for the big gif... Still working it out! 😄

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @AndreAnjos I don't see any SDK related question here but more a general issue with Cinema 4D. I personally think this is due to your Take but in any case please contact the Cinema 4D support https://support.maxon.net/index.php?lang=en_US

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        A 1 Reply Last reply Reply Quote 0
        • A
          AndreAnjos @m_adam
          last edited by

          Hi Maxime,

          Thank you for your help! 👍

          @m_adam said in Attaching image to camera calibrator adds offset to camera:

          Hi @AndreAnjos I don't see any SDK related question here but more a general issue with Cinema 4D.

          Mostly because the camera and take creation are all done with python, thought it could be a SDK issue.

          @m_adam said in Attaching image to camera calibrator adds offset to camera:

          I personally think this is due to your Take...

          That's a good guess with the takes, but it does it with the Main Take active. Would you know how could it influence my main take?

          @m_adam said in Attaching image to camera calibrator adds offset to camera:

          ...but in any case please contact the Cinema 4D support https://support.maxon.net/index.php?lang=en_US

          Will do that! ☺

          Cheers,

          Andre

          1 Reply Last reply Reply Quote 0
          • A
            AndreAnjos
            last edited by

            @m_adam said in Attaching image to camera calibrator adds offset to camera:

            but in any case please contact the Cinema 4D support https://support.maxon.net/index.php?lang=en_US

            Hi Maxime,

            After opening a ticket, support sent me here instead.
            Perhaps this is an issue with my code...

            Here's a snippet to see if this replicates to you:

            import c4d
            
            def create_camera(i, cam_name, lst):
                """
                Creates a camera with the correct name, variables and user data set.
                """
            
                cam = c4d.CameraObject()
                cam[c4d.ID_BASELIST_NAME] = '{:02d}_{}'.format(i, cam_name.capitalize())
                cam[c4d.CAMERAOBJECT_TARGETDISTANCE] = 1
            
                lst.append(cam)
                return lst
            
            def main():
                
                cam_names = ['intro_1', 'stats_1', 'feature_1', 'feature_2', 'feature_3', 'feature_4',
                         'feature_5', 'feature_6', 'feature_7', 'feature_8', 'outro_1']
                         
                global CAMS_LST
                CAMS_LST = []
            
                # Create and setup Cameras
                for i, cam in enumerate(cam_names, start=1):
                    CAMS_LST = create_camera(i, cam, CAMS_LST)
            
                for cam in CAMS_LST[::-1]:
            
                    doc.InsertObject(cam)
            
                outro_cal_tag = CAMS_LST[-1].MakeTag(1026818)  # Camera calibrator tag
                outro_cal_tag[c4d.CM_IMAGE_FILENAME] = ""  # <-------- Add any image path.
                outro_cal_tag[c4d.CM_LOUPE_SIZE_PIX] = 8
                outro_cal_tag[c4d.CM_LOUPE_MAGNIFICATION] = 1
            
                c4d.EventAdd()
                
            
            if __name__=='__main__':
                main()
            

            Cheers!

            Andre

            1 Reply Last reply Reply Quote 0
            • ManuelM
              Manuel
              last edited by Manuel

              hello,

              we though it was not code related sorry.

              Regarding your problem, it seems that with this tag there are some actions that are trigger only when you select the tag (this is done with a SceneHook)

              so the most direct way i found to trigger this is to simply select the tag with.

              doc.SetActiveTag(outro_cal_tag)   
              

              This trigger everything the tag need to update the camera parameters and so on. (and draw the image on the view)

              If you add the tag with the UI it will be selected and kick in. So this is a "normal" behavior (strange but normal)

              Cheers
              Manuel

              MAXON SDK Specialist

              MAXON Registered Developer

              1 Reply Last reply Reply Quote 0
              • A
                AndreAnjos
                last edited by

                @m_magalhaes said in Attaching image to camera calibrator adds offset to camera:

                hello,

                we though it was not code related sorry.

                Regarding your problem, it seems that with this tag there are some actions that are trigger only when you select the tag (this is done with a SceneHook)

                so the most direct way i found to trigger this is to simply select the tag with.

                doc.SetActiveTag(outro_cal_tag)   
                

                This trigger everything the tag need to update the camera parameters and so on. (and draw the image on the view)

                If you add the tag with the UI it will be selected and kick in. So this is a "normal" behavior (strange but normal)

                Cheers
                Manuel

                Hi Manuel,

                That makes sense! I couldn't understand how it was triggering in order to refresh the values, as usually the c4d.EventAdd() function does the trick.
                Did it work for you then? As I've tried the code above and still no luck. I'm adding your line after the value changes.

                Obrigado Manuel! 🙂

                Andre

                1 Reply Last reply Reply Quote 0
                • ManuelM
                  Manuel
                  last edited by Manuel

                  this code doesn't work with you ?

                  What version of Cinema 4D are you working with ? (I'm using 20.059)

                      outro_cal_tag = CAMS_LST[-1].MakeTag(1026818)  # Camera calibrator tag
                      outro_cal_tag[c4d.CM_IMAGE_FILENAME] = 'what ever file'  # <-------- Add any image path.
                      outro_cal_tag[c4d.CM_LOUPE_SIZE_PIX] = 8
                      outro_cal_tag[c4d.CM_LOUPE_MAGNIFICATION] = 1
                      doc.SetActiveTag(outro_cal_tag)
                      c4d.EventAdd()
                  

                  Cheers
                  Manuel

                  MAXON SDK Specialist

                  MAXON Registered Developer

                  A 1 Reply Last reply Reply Quote 0
                  • A
                    AndreAnjos @Manuel
                    last edited by

                    @m_magalhaes said in Attaching image to camera calibrator adds offset to camera:

                    this code doesn't work with you ?

                    What version of Cinema 4D are you working with ? (I'm using 20.059)

                        outro_cal_tag = CAMS_LST[-1].MakeTag(1026818)  # Camera calibrator tag
                        outro_cal_tag[c4d.CM_IMAGE_FILENAME] = 'what ever file'  # <-------- Add any image path.
                        outro_cal_tag[c4d.CM_LOUPE_SIZE_PIX] = 8
                        outro_cal_tag[c4d.CM_LOUPE_MAGNIFICATION] = 1
                        doc.SetActiveTag(outro_cal_tag)
                        c4d.EventAdd()
                    

                    Cheers
                    Manuel

                    Hi Manuel,

                    Thanks for coming back to me!

                    We have a copy of R20.059 and it definitely worked.
                    Our team currently works on R19.053 and I've tried again this morning and no luck. So not sure what's going on with it...

                    Thank you in advance!

                    Andre

                    1 Reply Last reply Reply Quote 0
                    • ManuelM
                      Manuel
                      last edited by

                      hi,

                      I've tried with the R19.053 and once I select the camera, the offsetY is already set to 0% (as it should)

                      to be sure with the code :

                      import c4d
                      
                      def create_camera(i, cam_name, lst):
                          """
                          Creates a camera with the correct name, variables and user data set.
                          """
                      
                          cam = c4d.CameraObject()
                          cam[c4d.ID_BASELIST_NAME] = '{:02d}_{}'.format(i, cam_name.capitalize())
                          cam[c4d.CAMERAOBJECT_TARGETDISTANCE] = 1
                      
                          lst.append(cam)
                          return lst
                      
                      def main():
                          
                          cam_names = ['intro_1', 'stats_1', 'feature_1', 'feature_2', 'feature_3', 'feature_4',
                                   'feature_5', 'feature_6', 'feature_7', 'feature_8', 'outro_1']
                                   
                          global CAMS_LST
                          CAMS_LST = []
                      
                          # Create and setup Cameras
                          for i, cam in enumerate(cam_names, start=1):
                              CAMS_LST = create_camera(i, cam, CAMS_LST)
                      
                          for cam in CAMS_LST[::-1]:
                      
                              doc.InsertObject(cam)
                      
                          outro_cal_tag = CAMS_LST[-1].MakeTag(1026818)  # Camera calibrator tag
                          outro_cal_tag[c4d.CM_IMAGE_FILENAME] = "C:\\Users\\Manuel Magalhaes\\Desktop\\texture\\CommonLizard.jpg"  # <-------- Add any image path.
                          outro_cal_tag[c4d.CM_LOUPE_SIZE_PIX] = 8
                          outro_cal_tag[c4d.CM_LOUPE_MAGNIFICATION] = 1
                          doc.SetActiveTag(outro_cal_tag)
                          c4d.EventAdd()
                          
                      
                      if __name__=='__main__':
                          main()
                      

                      MAXON SDK Specialist

                      MAXON Registered Developer

                      1 Reply Last reply Reply Quote 0
                      • A
                        AndreAnjos
                        last edited by

                        Hi Manuel,

                        Right! Found the culprit... symbolcache file...
                        Couldn't understand how it was working for you and not for me.
                        After deleting symbolcache worked straight away and it seems that also works without having

                        doc.SetActiveTag(outro_cal_tag)
                        

                        Thank you very much for your awesome help with this! ☺

                        Andre

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post