Skip to content

Commit 1456a95

Browse files
committed
Changes: Quality definitions to standard jpeg quality
1 parent b31c83d commit 1456a95

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,15 @@ make USER_C_MODULES=../../../../micropython-camera-API/src/micropython.cmake BOA
110110
```
111111

112112
If you experience problems, visit [MicroPython external C modules](https://docs.micropython.org/en/latest/develop/cmodules.html).
113+
113114
## Notes
114115

115116
- The OV5640 pinout is compatible with boards designed for the OV2640 but the voltage supply is too high for the internal 1.5V regulator, so the camera overheats unless a heat sink is applied. For recording purposes the OV5640 should only be used with an ESP32S3 board. Frame sizes above FHD framesize should only be used for still images due to memory limitations.
116117
- If your target board is a ESP32, I recommend using IDF >= 5.2, since older versions may lead to IRAM overflow during build. Alternatively you can modify your sdkconfig-file (see [issue #1](https://github.com/cnadler86/micropython-camera-API/issues/1)).
117118

118119
## Plans for the future
119-
- [ ] imolrment structure in repo to include other boards like xiao sense
120+
121+
- [ ] implement structure in repo to include other boards like xiao sense
120122
- [ ] harmonize properties to standard ones at API level, e.g. jpeg quality to the range 100=very good, 1/0= very bad
121123
- [ ] edge case: enable usage of pins such as i2c for other applications
122-
- [ ] provide examples in binary image with lfs-merge
124+
- [ ] provide examples in binary image with lfs-merge

src/modcamera.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void mp_camera_hal_construct(
9191
// configure camera based on arguments
9292
self->camera_config.pixel_format = pixel_format;
9393
self->camera_config.frame_size = frame_size;
94-
self->camera_config.jpeg_quality = jpeg_quality; //0-63 lower number means higher quality. TODO: Harmonization in API and Validation
94+
self->camera_config.jpeg_quality = (int8_t)map(jpeg_quality,0,100,63,0); //0-63 lower number means higher quality. TODO: Harmonization in API and Validation
9595
self->camera_config.pin_d0 = data_pins[0];
9696
self->camera_config.pin_d1 = data_pins[1];
9797
self->camera_config.pin_d2 = data_pins[2];
@@ -364,7 +364,7 @@ SENSOR_STATUS_GETSET_IN_RANGE(int, saturation, saturation, set_saturation, -2, 2
364364
SENSOR_STATUS_GETSET_IN_RANGE(int, sharpness, sharpness, set_sharpness, -2, 2);
365365
SENSOR_STATUS_GETSET(int, denoise, denoise, set_denoise);
366366
SENSOR_STATUS_GETSET(mp_camera_gainceiling_t, gainceiling, gainceiling, set_gainceiling);
367-
SENSOR_STATUS_GETSET(int, quality, quality, set_quality); //in_Range not needed since driver limits value
367+
SENSOR_STATUS_GETSET(int, quality_raw, quality, set_quality); //in_Range not needed since driver limits value. Raw to be used in wrapper funtion
368368
SENSOR_STATUS_GETSET(bool, colorbar, colorbar, set_colorbar);
369369
SENSOR_STATUS_GETSET(bool, whitebal, awb, set_whitebal);
370370
SENSOR_STATUS_GETSET(bool, gain_ctrl, agc, set_gain_ctrl);
@@ -384,6 +384,14 @@ SENSOR_STATUS_GETSET(bool, wpc, wpc, set_wpc);
384384
SENSOR_STATUS_GETSET(bool, raw_gma, raw_gma, set_raw_gma);
385385
SENSOR_STATUS_GETSET(bool, lenc, lenc, set_lenc);
386386

387+
int mp_camera_hal_get_quality(mp_camera_obj_t *self){
388+
return map(mp_camera_hal_get_quality_raw(self),63,0,0,100);
389+
}
390+
391+
void mp_camera_hal_set_quality(mp_camera_obj_t *self,int quality){
392+
mp_camera_hal_set_quality_raw(self,map(quality,0,100,63,0));
393+
}
394+
387395
mp_camera_pixformat_t mp_camera_hal_get_pixel_format(mp_camera_obj_t *self) {
388396
return self->camera_config.pixel_format;
389397
}

0 commit comments

Comments
 (0)