Closed jasperchih closed 3 years ago
Hi,
There is only single function in the camera
module called capture()
which captures JPG image and returns that as a buffer. You can see it being used in the web server script webcam.py. It returns the image as HTTP response, but it could just as well be saved into a file.
The capture()
function currently does not take any parameters, so there is no control over the detailed sensor settings. You can see the C implementation calling the camera driver here with those hardcoded sensor settings.
Hi, Can you send me a copy of your bin file? the email is renyichong@outlook.com
I uploaded firmware image here https://github.com/tsaarni/esp32-micropython-webcam/releases/tag/2019-02-24
Hi, thanks for the upload... i measure the power consumption result (shown in below) and looks very close with my compiled code. i feel exciting and appreciate on your notes. but,, the remain question is : how to create the camera settings Python method? For example, "camera.resolution(XXXX)". Please let me know which file to start with if possible.
thanks
The methods can be implemented in this file https://github.com/tsaarni/micropython-with-esp32-cam/blob/esp32-camera-for-micropython/ports/esp32/modcamera.c by following the example of existing methods. I used this document as reference how to add methods to micropython. You'll find also how to add methods with arguments, that is, how to convert between Python and C data types. Rest of the type conversion methods are defined here.
The functions to control the sensor seem to be listed here. To controlling resolution, I only find set_framesize()
which takes enumeration framesize_t
argument (defined in the same file). I'm not sure though, if this is the only way to control resolution.
So I think minimum viable code could look something along the lines like this
STATIC mp_obj_t camera_set_framesize(mp_obj_t framesize_obj){
framesize_t framesize_enum = mp_obj_int_get_truncated(framesize_obj);
sensor_t *control = esp_camera_sensor_get();
control->set_framesize(control, framesize_enum);
return mp_const_true;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(camera_set_framesize_obj, camera_set_framesize);
STATIC const mp_rom_map_elem_t camera_module_globals_table[] = {
// all the existing methods remain also here but add following....
{ MP_ROM_QSTR(MP_QSTR_capture), MP_ROM_PTR(&camera_set_framesize_obj) },
}
Of course this would leave lot to be desired from usability and error handling. Note: I have not tested this, so it probably does not even compile, but I hope it provides a starting point anyway!
I checked the resolution issue a bit more and I suspect that the sensor has fixed resolution options. So maybe rest would need to be done in software.
If you look at the driver the set_framesize()
function for ov2640 supports only three options out of the framesize_t
enum: UXGA, SVGA, CIF. The information in the datasheet of ov2640 seems to match (see bits for resolution selection in table 13 on page 24).
Hi,
i completed to build the ESP32-CAM support micropython bin file and loaded to the board. The current consumption looks reasonable. But, no idea on how to capture the image and save into a file. Can you help on an example script ? Or, please advise how to check out the supported class function. thanks million.
jasper