How to focus with 16MP IMX519 Autofocus Synchronized Quad-Camera Kit?

My goal is to focus each camera frame.

The problem is that i2cset is specific to the I2CBUS. So, I do not know how to just adjust the channel 0/1/2/3 separately.

My expectation is that I can adjust the focus of each camera separately.

My actual result is that I adjust the focus based on the combined frame which resulted in poor focus.

What I plan:

  1. I plan to switch channel 0/1/2/3 and do this instructions when I started the camera:
    a. switch channel 0/1/2/3
    b. do autofocus
    c. remember the max value.

Usage:
a. switch camera by calling a method i.e. camera.channel(0), the camera will automatically refocus to the saved max value.

Unfortunately, I believe this will strain the camera lens overtime as I will need the frame from every camera every 1 second.

void Focuser::write(int value) {
    if (value < 0) {
        value = 0;
    }

    if (verbose) {
        std::cout << "write: " << value << std::endl;
    }

    value = static_cast<int>(value / 1000.0 * 4095);

    value <<= 4;
    std::stringstream command;
    command << "i2cset -y " << I2CBUS << " 0xc 0x0 0x" << std::hex << (value >> 8);
    int status = std::system(command.str().c_str());
    if (verbose) std::cout << command.str() << std::endl;
    if ((status >> 8) == 1) {
        std::cerr << "ERROR: " << command.str() << " exit status is 1" << std::endl;
        exit(1);
    }
    
    command.str("");
    command << "i2cset -y " << I2CBUS << " 0xc 0x1 0x" << std::hex << (value & 0xFF);
    status = std::system(command.str().c_str());
    if (verbose) std::cout << command.str() << std::endl;
    if ((status >> 8) == 1) {
        std::cerr << "ERROR: " << command.str() << " exit status is 1" << std::endl;
        exit(1);
    }
}

@kidfrom
You can switch channels to accomplish this

Don’t worry about the title of the question, the registers for switching channels are unified.

Noted, I can switch channels to accomplish this but I am worried about the lens of IMX519 as I will need to switch between channel 0/1/2/3 every 1 second.

Can you confirm that:

  1. You can’t focus each camera while in four in one mode.
  2. You can switch between camera and do focus i2cset -y I2CBUS 0xc 0x0 SAVED_VALUE Then i2cset -y I2CBUS 0xc 0x1 SAVED_VALUE. SAVED_VALUE is the known value with maximum sharpness. There is risk of straining the lens over time if you switch between camera and do focus

@kidfrom

Even if you switch to single-channel mode, every time you focus, it will trigger other channel cameras to focus together. (We recommend four cameras focus on places at the same distance)

What kind of risk is this, can you elaborate? I couldn’t understand what it meant.

Noted that Arducam recommend four camera focus on places at the same distance.

From where I see it:

  1. Four-channel mode can work but the rescaling done by UC-512 maybe an issue (the image will be too small)
  2. Single-channel mode can work but the focus will be based on 1 camera instead of each camera have it’s own focus value.

There is risk of straining the lens over time if you switch between camera and do focus

From what I see the steps that I need to do if we go with the single-channel mode and switch between camera:

  1. Turn on the C++ app
  2. Do autofocus for each camera and find the value with maximum sharpness.

loop every 1/4 seconds:

  1. Switch to cam0 and call focuser.set(value), value which have maximum sharpness for cam0.
  2. Switch to cam1 and call focuser.set(value).
  3. cam2, cam3

Since this use motorized lens, I believe this will strain the camera. Other option is to follow your advice to focus on places at the same distance and to skip calling focuser.set(value) everytime we switch camera.

Yes, this is also the original intention of the design.have more field of view