JPEG capture: setJpegQuality not working as expected

Dear Ameba team,

We are currently using config.setJpegQuality(val) before applying the configuration, but we don’t see any noticeable difference in the captured image.

The value of val is set between 1 and 9, and we are using the default F37 camera. Could you please confirm whether this API is already implemented and functional?

We also checked the generated JPEG files, and it appears that the quantization tables in the header remain unchanged.

If it is not yet working, could you kindly let us know when this feature is expected to be available?

Thank you very much for your support.

below is a partial example:

VideoSetting config(VIDEO_FHD, CAM_FPS, VIDEO_JPEG, 1);

//init code
config.setJpegQuality(val);
Camera.configVideoChannel(CHANNEL,config);
Camera.videoInit();
Camera.channelBegin(CHANNEL);

String path = String(fs.getRootPath()) + String(FILENAME) + "_q" + input + ".jpg";
File file = fs.open(path);

delay(1000);
Camera.getImage(CHANNEL, &img_addr, &img_len);
file.write((uint8_t *)img_addr, img_len);
Serial.print(path);
Serial.println("  Save.");

file.close();
fs.end();
}

Hi @Howard ,

The order of calling config.setJpegQuality(val) in your partial example is correct. It should overwrite the default value set in the SDK. Upon checking, this API is functional and the effect is reflected in the pixel contour and file size of the image. Would you mind to verify the change in file size when different Jpeg quality value is set?

Thank you.

Dear @KevinKL ,

I tried this function again and found that my testing video types do not send the quality value to the camera in VideoStream.cpp. After fixing this, we are now able to adjust the quality setting and observe changes in file size. However, even when the quality is set to 9, the image quality does not improve significantly.

thanks

Hi @Howard ,

Unfortunately, Jpeg quality level 9 is the maximum to set. You may consider changing the ISP settings using CameraSetting API, they shall be called after channelBegin()

    config.setJpegQuality(9);
    Camera.configVideoChannel(CHANNEL, config);
    Camera.videoInit();
    Camera.channelBegin(CHANNEL);
    configCam.setSharpness(75);
    configCam.setContrast(60);
    configCam.setLDC(1);

    fs.begin();
    File file = fs.open(String(fs.getRootPath()) + String(FILENAME));

    delay(1000);
    Camera.getImage(CHANNEL, &img_addr, &img_len);
    file.write((uint8_t *)img_addr, img_len);
    file.close();
    fs.end();

Additionally, there is a tool for Image Quality (IQ) tuning, ameba-tool-rtos-pro2/IQ Tuning at main · Ameba-AIoT/ameba-tool-rtos-pro2 · GitHub , you may refer to this guide. Please let us know if you are interested in using this tool.

Thank you.