Autofocus issues

Published by Astrid on

Viewing 30 reply threads
  • Author
    Posts
    • #22330
      Astrid
      Participant

      Hi,

      Here is my Raspbian version,

      Raspbian GNU/Linux 10 (buster)

      and I use Autofocus.py by Python 3.7.3

      At first, the result was great, however after I executed few times(it happened randomly), there is an issue where the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      The only way I found to solve it rebooting my Raspberry Pi.

      I had already checked the connection between camera and raspberry Pi and the FPC cable.

      Is there any way to solve it?

      Thank you.

    • #22375
      bin
      Keymaster

      Hi,

      It is due to the i2c busy is busy. The camera and the focus motor will share the i2c bus.

      You can try to disable the camera’s auto exposure  and auto white balance function and retry it.

      What we can do is try our best to do not let the camera occupy the i2c bus.

      Let me know if you need more help.

       

       

    • #22470
      Astrid
      Participant

      This works perfectly. Thanks for your reply!

    • #22527
      bin
      Keymaster

      Hi,

      Great to hear you have solved your problems.

    • #22773
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.

      According the position where I called time.sleep(), camera preview would get different results, but the focal distance seems to be the same, and I have no idea why this would happen.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      Is there anything I should do but I didn’t?

      Thank you so much for your answers.

    • #22774
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.

      According the position where I called time.sleep(), camera preview would get different results.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22775
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.

      According the position where I called time.sleep(), camera preview would get different results.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22776
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.

      AFissue

      According the position where I called time.sleep(), camera preview would get different results.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22777
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.


      According the position where I called time.sleep(), camera preview would get different results.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22778
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.

      According the position where I called time.sleep(), camera preview would get different results.Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22779
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.

      https://imgur.com/VWACMbn

      According the position where I called time.sleep(), camera preview would get different results.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22780
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.

      According the position where I called time.sleep(), camera preview would get different results.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22786
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.

      According the position where I called time.sleep(), camera preview would get different results.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22782
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.

      According the position where I called time.sleep(), camera preview would get different results.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22781
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.

      View post on imgur.com

      According the position where I called time.sleep(), camera preview would get different results.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22783
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.

      View post on imgur.com

      According the position where I called time.sleep(), camera preview would get different results.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22785
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.


      According the position where I called time.sleep(), camera preview would get different results.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22784
      Astrid
      Participant

      Hi,

      Here is another issue I found these days.


      According the position where I called time.sleep(), camera preview would get different results.

      Although the second way gets better preview, however, the i2c channels fill up and the code returns the error: picamera.exc.
      Pi CameraMMAL Error: Failed to enable connection: Out of resources.

      And the first way executed perfectly, and the focal distance I got seems to be the same as the second way, and I have no idea why this would happen.

      Is there anything I should do but I didn’t?

      Thank you so much for helping me.

    • #22833
      bin
      Keymaster

      Hi,

      Please attach me your whole code and I will help you test it and reply you as soon as possible.

       

    • #22836
      Astrid
      Participant

      Hi,

      Here is my whole code, an error occurs when AF the image about 60-100 times, then the i2c channels filled up.

      https://pastebin.com/XkPpAhmq

       

    • #22903
      bin
      Keymaster

      Hi,

      Thanks for your whole code. Tomorrow I will invite our engineer help you test it .

       

    • #22970
      bin
      Keymaster

      Hi,

      We try to run  the code you send and get this error and we can’t install the matplotlib Please help

    • #22978
      Astrid
      Participant

      Sorry, I forgot to remove the library I used for debugging

      You can import these library only, and I think it can also works.

      import cv2
      import numpy as np
      import os
      import time
      import smbus2 as smbus

      try:
      import picamera
      from picamera.array import PiRGBArray
      except:
      sys.exit(0)

       

      If there is any problem, please tell me and I’ll reply as soon as possible, thank you.

    • #23006
      bin
      Keymaster

      OK, I will test it next Monday. Now is weekend. Thanks for your patient.

       

    • #23294
      Astrid
      Participant

      Hi,

      Did you successfully run my code? I’ve tried many ways to fix the i2c filled up problem this week, but still not work.

       

    • #23442
      bin
      Keymaster

      Hi,

      Very very sorry for reply you so late, I am too busy recently. Please ry this test I attached for you.

      Notice, Please ensure you have enable the i2c0  add dtparam=i2c_vc=on

    • #23443
      bin
      Keymaster

      This is the test demo  I attached for you

      Attachments:
      You must be logged in to view attached files.
    • #23549
      Astrid
      Participant

      Thank you so much for replying.

      I have some questions here.

      Why the test demo you attached set the camera like this:

      camera.shutter_speed = camera.exposure_speed
      camera.exposure_mode = ‘auto’
      # g = camera.awb_gains
      camera.awb_mode = ‘auto’
      # camera.awb_gains = g

      time.sleep(2)

      Does this mean we don’t have to disable the camera’s auto exposure  and auto white balance if we set dtparam=i2c_vc=on?

       

       

    • #23698
      bin
      Keymaster

      Yes, now we use the same i2c adapter as the GPU, it seems the GPU will detected if the i2c0 is busy. So it will not exist write write error.

      Before, we connect the i2c1 and i2c0 the same bus. which will exist occupied.

      Have you tested this demo I attached for you?

       

    • #23708
      Astrid
      Participant

      Yes, it works very well.

      Thank you so much!

    • #23802
      bin
      Keymaster

      You are welcome. Let me know if you need more help.

       

Viewing 30 reply threads
  • You must be logged in to reply to this topic.