VEYE IMAGING Forum
    • Categories
    • Tags
    • Recent
    • Popular
    • Users
    • WIKI
    • veye.cc
    • Register
    • Login

    IMX178 roi problem - rpi5

    Scheduled Pinned Locked Moved Machine Vision camera
    11 Posts 2 Posters 4.3k Views 1 Watching
    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.
    • S Offline
      sanlu
      last edited by

      Hello,
      I can't set proper roi on rpi5 and imx178 . Command history:

      ./media_setting_rpi5.sh mvcam -fmt RAW8 -w 3088 -h 2064
      This is a Raspberry Pi 5.
      camera name mvcam; width 3088; height 2064; media_fmt Y8_1X8; pixel_fmt GREY
      CAM1 probed: media device is /dev/media2
      set CAM1 finish, plese get frame from /dev/video0 and use /dev/v4l-subdev2 for camera setting
      # v4l2-ctl --set-fmt-video=width=2600,height=2064 -d /dev/video0
      # v4l2-ctl -d /dev/video0 --set-fmt-video=width=2600,height=2064,pixelformat=GREY --stream-mmap --stream-count=1 --stream-to=y8-2600x2064.raw
        VIDIOC_STREAMON returned -1 (Invalid argument)
      # v4l2-ctl -d /dev/video0 --set-fmt-video=width=3088,height=2064,pixelformat=GREY --stream-mmap --stream-count=1 --stream-to=y8-2600x2064.raw
      <
      

      (data captured)

      Second example:

      # ./media_setting_rpi5.sh mvcam -fmt RAW8 -w 2600 -h 2064 -c 1
      # v4l2-ctl --set-ctrl roi_x=100 -d /dev/v4l-subdev2
      # gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=1 ! "video/x-raw,format=GRAY8,width=2600,height=2064, framerate=25/1" ! jpegenc ! filesink location=/tmp/test_roi100.jpg
      

      no matter what "number" I set in "v4l2-ctl --set-ctrl roi_x='number'"
      there is no effect on image - always roi begins at 0,0.
      Script ./mv_mipi_i2c.sh -r -f roi -b 4
      always return: r roi is 0,0,2600,2064

      Second problem is "overflow" at 256 pixels in setting roi by mv_mipi_i2c.sh. Image captured after setting roi:

       ./mv_mipi_i2c.sh -w -f roi -p1 256 -p2 0 -p3 2600 -p4 2064 -b 4
      

      Is the same when:

       ./mv_mipi_i2c.sh -w -f roi -p1 0 -p2 0 -p3 2600 -p4 2064 -b 4; 
      

      setting x-offset at maximus 248 pix works ok:
      ./mv_mipi_i2c.sh -w -f roi -p1 248 -p2 0 -p3 2600 -p4 2064 -b 4;

      veye_xummV 1 Reply Last reply Reply Quote 0
      • veye_xummV Offline
        veye_xumm @sanlu
        last edited by

        @sanlu First example:
        media_setting_rpi5.sh has internally called media-ctl and v4l2-ctl to configure the resolution. So there is no need to run v4l2-ctl after calling media_setting_rpi5.sh.
        Try this:

        ./media_setting_rpi5.sh mvcam -fmt RAW8 -w 3088 -h 2064 -c 1
        v4l2-ctl -d /dev/video0 --stream-mmap --stream-count=1 --stream-to=y8-3104x2064.raw
        

        Second example:

        The configuration of roi requires all 4 relevant parameters to be configured together, not just one. This will not take effect.

        Questions will be answered as soon as possible, please be patient.
        如果你使用中文,请直接用中文提问。
        May the force be with YOU. (This is the translation of the mysterious Chinese symbol above.)

        S 1 Reply Last reply Reply Quote 0
        • S Offline
          sanlu @veye_xumm
          last edited by

          @veye_xumm Your example at full resolution works fine. I don't want full resolution but width 2400px centered - it require ROI offseted by 344px, but after setting roi via mv_mipi_i2c.sh script (./mv_mipi_i2c.sh -w -f roi -p1 344 -p2 0 -p3 2400 -p4 2064 -b 4) image is offseted only 88px - offset is "modulo" 256px (i've send you images via e-mail).

          Second example: How to set all 4 param in one command while "v4l2-ctl --set-ctrl roi_x " works on device /dev/v4l-subdev2 during "v4l2-ctl --set-fmt-video" works on /dev/video0 ?

          veye_xummV 1 Reply Last reply Reply Quote 0
          • veye_xummV Offline
            veye_xumm @sanlu
            last edited by

            @sanlu

            Sorry, I didn't explain clearly earlier.

            Based on your requirements, I recommend not using mv_mipi_i2c.sh for configuration because it directly changes the settings inside the camera, but the v4l2 driver won't be aware of your parameter modifications.

            The following three commands form a complete ROI configuration:

            v4l2-ctl --set-ctrl roi_x=344 
            v4l2-ctl --set-ctrl roi_y=0
            v4l2-ctl --set-fmt-video=width=2400,height=2064
            

            As for the module issue you mentioned, after performing the above configuration, use the following commands to verify the actual parameters inside the camera:

            mv_mipi_i2c.sh -r -f roi -b yourbus
            mv_mipi_i2c.sh -r -f version -b yourbus
            

            Please send me the results once you've checked.

            Questions will be answered as soon as possible, please be patient.
            如果你使用中文,请直接用中文提问。
            May the force be with YOU. (This is the translation of the mysterious Chinese symbol above.)

            S 1 Reply Last reply Reply Quote 0
            • S Offline
              sanlu @veye_xumm
              last edited by

              @veye_xumm Results:

              # ./media_setting_rpi5.sh mvcam -fmt RAW8 -w 2400 -h 2064 -c 1
              This is a Raspberry Pi 5.
              camera name mvcam; width 2400; height 2064; media_fmt Y8_1X8; pixel_fmt GREY
              CAM1 probed: media device is /dev/media1
              set CAM1 finish, plese get frame from /dev/video0 and use /dev/v4l-subdev2 for camera setting
              # v4l2-ctl --set-ctrl roi_x=344 -d /dev/v4l-subdev2 
              # v4l2-ctl --set-ctrl roi_y=0 -d /dev/v4l-subdev2 
              # v4l2-ctl --set-fmt-video=width=2400,height=2064 -d /dev/video0
              # ./mv_mipi_i2c.sh -r -f roi -b 4
              r roi is 0,0,2400,2064 
              # ./mv_mipi_i2c.sh -r -f version -b 4
              version is C 01.36 and L 02.01
              
              veye_xummV 1 Reply Last reply Reply Quote 0
              • veye_xummV Offline
                veye_xumm @sanlu
                last edited by

                @sanlu
                Please download a new https://github.com/veyeimaging/raspberrypi_v4l2/tree/main/rpi5_scripts
                Try

                ./media_setting_rpi5.sh mvcam -fmt RAW10 -x 344 -y 0 -w 2400 -h 2064 -c 1
                

                then

                mv_mipi_i2c.sh -r -f roi -b yourbus
                

                Questions will be answered as soon as possible, please be patient.
                如果你使用中文,请直接用中文提问。
                May the force be with YOU. (This is the translation of the mysterious Chinese symbol above.)

                S 1 Reply Last reply Reply Quote 0
                • S Offline
                  sanlu @veye_xumm
                  last edited by

                  @veye_xumm Results below:

                  root@allsky2:~/raspberrypi_v4l2/rpi5_scripts# ./media_setting_rpi5.sh mvcam -fmt RAW10 -x 344 -y 0  -w 2400 -h 2064 -c 1
                  This is a Raspberry Pi 5.
                  Kernel version is 6.6.51, do not support unpacked format.
                  camera name mvcam; roi_x 344; roi_y 0;width 2400; height 2064; media_fmt Y10_1X10; pixel_fmt Y10P
                  CAM1 probed: media device is /dev/media1
                  set CAM1 finish, plese get frame from /dev/video0 and use /dev/v4l-subdev2 for camera setting
                  root@allsky2:~/raspberrypi_v4l2/rpi5_scripts# cd ../mv_tools_rpi/
                  /root/raspberrypi_v4l2/mv_tools_rpi
                  root@allsky2:~/raspberrypi_v4l2/mv_tools_rpi# ./mv_mipi_i2c.sh -r -f roi -b 4
                  r roi is 0,0,2400,2064 
                  
                  veye_xummV 1 Reply Last reply Reply Quote 0
                  • veye_xummV Offline
                    veye_xumm @sanlu
                    last edited by

                    @sanlu said in IMX178 roi problem - rpi5:

                    ./media_setting_rpi5.sh mvcam -fmt RAW10 -x 344 -y 0 -w 2400 -h 2064 -c 1

                    Sorry , please pull a new update from github.

                    Questions will be answered as soon as possible, please be patient.
                    如果你使用中文,请直接用中文提问。
                    May the force be with YOU. (This is the translation of the mysterious Chinese symbol above.)

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      sanlu
                      last edited by

                      @veye_xumm Ok - now "mv_mipi_i2c.sh -r -f roi" show right values, but main problem exists: image not begin at 344px but 88.
                      But problem exists only at "x" - I've tested image 1200x1200 offseted by 512 and "y" begins at right position

                      veye_xummV 1 Reply Last reply Reply Quote 0
                      • veye_xummV Offline
                        veye_xumm @sanlu
                        last edited by

                        @sanlu
                        This is indeed a bug, please refer to this link below to upgrade the camera firmware to version MV-MIPI-IMX178M_C1.44_L2.01_upgrade_20241121.bin.

                        Questions will be answered as soon as possible, please be patient.
                        如果你使用中文,请直接用中文提问。
                        May the force be with YOU. (This is the translation of the mysterious Chinese symbol above.)

                        S 1 Reply Last reply Reply Quote 0
                        • S Offline
                          sanlu @veye_xumm
                          last edited by

                          @veye_xumm
                          Perfect. Now is working as expected. Thanks!

                          1 Reply Last reply Reply Quote 0

                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                          With your input, this post could be even better 💗

                          Register Login
                          • First post
                            Last post