Need Help with Manual Exposure & Gain Control on IMX415 (Owlow OS, Rockchip ISP)

@IamGray
please help me as i have posted the further query .

Hello @gita.kumari , This is the document about manual control cameras.

And there are some referance codes in external_camera_engine_rkaiq/rkisp_demo/demo/sample/*cpp

Rockchip_Development_Guide_ISP30_EN_v1.2.5.pdf (2.5 MB)

1 Like

We have deployed multiple Edge2 + camera units in an indoor setup. The lighting is generally controlled, but the field of view also includes areas with sunlight reflections.

We are observing the following issues:

  • Blurry or out-of-focus images

  • Human figures appearing distorted or “alien-like” under certain lighting

  • Focus not locking properly on target objects

  • Inconsistent performance across multiple devices at the same location

We suspect this may be related to lighting reflections, autofocus behavior, or camera processing configuration. Could you please investigate and suggest the optimal camera or Edge2 settings (e.g., exposure, white balance, focus mode, compression parameters) to achieve stable and clear imaging?

Looking forward to your guidance.

Additional Information:
We are currently using auto settings and do not want to switch to manual focus.

Note:
I was able to run the Git code and verified the demo — the CLI-driven menu appears and works correctly. However, I am not able to set certain parameters such as Manual white balance and other related settings.

@IamGray
We have deployed multiple Edge2 + camera units in an indoor setup. The lighting is generally controlled, but the field of view also includes areas with sunlight reflections.

We are observing the following issues:

  • Blurry or out-of-focus images

  • Human figures appearing distorted or “alien-like” under certain lighting

  • Focus not locking properly on target objects

  • Inconsistent performance across multiple devices at the same location

We suspect this may be related to lighting reflections, autofocus behavior, or camera processing configuration. Could you please investigate and suggest the optimal camera or Edge2 settings (e.g., exposure, white balance, focus mode, compression parameters) to achieve stable and clear imaging?

Looking forward to your guidance.

Additional Information:
We are currently using auto settings and do not want to switch to manual focus.

Note:
I was able to run the Git code and verified the demo — the CLI-driven menu appears and works correctly. However, I am not able to set certain parameters such as Manual white balance and other related settings.

@gita.kumari It seems there maybe an issue with the rockchip provided libraries (librkaiq.so), as I can replicate the same issue you are facing at the moment. For instance I used this example repo as a point of reference:

This is a modified version of the rkaiq_3A_server, if you take a look at the camera_engine_rkaiq libraries, you can note that the RK3588 which uses the ISP30, relies on the uAPI2 library, which does not actually have any function calls for operations like exposure timing etc.

There is no way to manually modify the parameters without recompiling and running every time, so I did attempt to modify this by adding functionality to use TCP/IP as way to send updated parameters.

void *socket_thread(void* arg){
struct rkaiq_media_info *media_infos;
char buffer[BUFFER_SIZE];
paRange_t range;

media_infos = (struct rkaiq_media_info *) arg;

for(;;){
    ssize_t bytes_received = recvfrom(rkaiq_socket_fd, buffer, BUFFER_SIZE - 1, 0,
                                    (struct sockaddr*)&client_addr, &client_addr_len);

    if(bytes_received < 0) continue;

	if(json::accept(std::string(buffer))){
	    json config_json = json::parse(std::string(buffer));

		if(config_json.contains("camera_id")){
	    	int idx = (int)config_json["camera_id"];
		    rkaiq_media_info *media_info = &media_infos[idx];

	    	DBG("Applying settings...\n");

            if(config_json.contains("ae")) {
				rkaiq_isp_ctrl[idx].ae = (bool)config_json["ae"];

				if(rkaiq_isp_ctrl[idx].ae) rk_aiq_uapi2_setExpMode(media_info->aiq_ctx, OP_AUTO);
    	        else rk_aiq_uapi2_setExpMode(media_info->aiq_ctx, OP_MANUAL);
    	   		DBG("Exposure mode modified\n");
			}

			if(config_json.contains("shutter_time")) {
				rkaiq_isp_ctrl[idx].shutter_time = (float)config_json["shutter_time"];

				range.min = range.max = rkaiq_isp_ctrl[idx].shutter_time;
				rk_aiq_uapi2_setExpTimeRange(media_info->aiq_ctx, &range);
			}

			if(config_json.contains("gain")) {
				rkaiq_isp_ctrl[idx].gain = (float)config_json["gain"];

				range.min = range.max = rkaiq_isp_ctrl[idx].gain;
				rk_aiq_uapi2_setExpGainRange(media_info->aiq_ctx, &range);
			}

            if(config_json.contains("awb")) {
				rkaiq_isp_ctrl[idx].awb = (bool)config_json["awb"];

				if(rkaiq_isp_ctrl[idx].awb) rk_aiq_uapi2_setWBMode(media_info->aiq_ctx, OP_AUTO);
    		    else rk_aiq_uapi2_setWBMode(media_info->aiq_ctx, OP_MANUAL);
    		    DBG("White Balance mode modified\n");
			}

			if(config_json.contains("hue")) {
				rkaiq_isp_ctrl[idx].hue = (unsigned int)config_json["hue"];
		   		rk_aiq_uapi2_setHue(media_info->aiq_ctx, rkaiq_isp_ctrl[idx].hue);
			}

			if(config_json.contains("saturation")) {
				rkaiq_isp_ctrl[idx].saturation = (unsigned int)config_json["saturation"];
				rk_aiq_uapi2_setSaturation(media_info->aiq_ctx, rkaiq_isp_ctrl[idx].saturation);
			}

			if(config_json.contains("brightness")) {
				rkaiq_isp_ctrl[idx].brightness = (unsigned int)config_json["brightness"];
				rk_aiq_uapi2_setBrightness(media_info->aiq_ctx, rkaiq_isp_ctrl[idx].brightness);
			}

			if(config_json.contains("contrast")) {
				rkaiq_isp_ctrl[idx].contrast = (unsigned int)config_json["contrast"];
				rk_aiq_uapi2_setContrast(media_info->aiq_ctx, rkaiq_isp_ctrl[idx].contrast);
			}

			if(config_json.contains("sharpness")) {
				rkaiq_isp_ctrl[idx].sharpness = (unsigned int)config_json["sharpness"];
				rk_aiq_uapi2_setSharpness(media_info->aiq_ctx, rkaiq_isp_ctrl[idx].sharpness);
			}

			if(config_json.contains("color_temperature")) {
				rkaiq_isp_ctrl[idx].color_temperature = (unsigned int)config_json["color_temperature"];
				rk_aiq_uapi2_setMWBCT(media_info->aiq_ctx, rkaiq_isp_ctrl[idx].color_temperature);
			}
		} else {
			continue;
		}
	}

	sleep(1);
}
}

rkisp_server_3A.cpp.txt (14.2 KB)

json.hpp.txt (959.9 KB)

You can try adding these two files as .cpp and .hpp to the above and build it.
you will also need to clone the rockchip headers inside the project folder, and rename it

cd rockchip-isp-demo
git clone https://github.com/khadas/external_camera_engine_rkaiq
mv external_camera_engine_rkaiq camera_engine_rkaiq

Then just build with make, disable the default rkaiq_3A_server service, and run this server from within the build folder with sudo, for sending the control parameters you can use any software to send the tcp packet, but I’ve attached an example using python

client.py.txt (1002 Bytes)

        # Sample JSON data to send
        json_data = {
            "camera_id": 5,
            "shutter_speed": 0.001
        }

Note: you need to modify camera_id, based on which camera port you use, you can find that out from the debug log from the server.

This is all just purely experiemental, and there are some bugs in the rockchip libraries, which makes the server update parameters inconsistently, hoping some update from rockchip can allow this solution to operate much better.

Cheers

1 Like

@Elethere
Threr are some bugs in the rockchip libraries, which makes the server update parameters inconsistently
If I ma not wrong this is for default ISP loads on boot not for the current compiled one ?

when we can expect the updated library from rockchip
so that we can do all the operations on provided node as we do for exposure and gain on subdev2 and subdev3 for /dev/video33
and also found the same support for other video node 55
.

@gita.kumari no idea about it, but if it’s possible for rockchip engineers to provided a consistent working demo of their software, it would be good as it seems this current software release is not working as expected.

maybe @Nick_Xie @IamGray can confirm with rockchip engineers on this topic.