1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 
5 #include "py/mperrno.h"
6 #include "py/obj.h"
7 #include "py/runtime.h"
8 #include "py/builtin.h"
9 
10 #include "ulog/ulog.h"
11 #include "base/modules/c/include/WrapperIHaasImageCodec.h"
12 
13 #define LOG_TAG "IMAGE_CODEC"
14 
15 extern const mp_obj_type_t minicv_imagecodec_type;
16 // this is the actual C-structure for our new object
17 typedef struct
18 {
19     // base represents some basic information, like type
20     mp_obj_base_t Base;
21     // a member created by us
22     char *ModuleName;
23     CodecImageType_t mtype;
24     void            *mInstance;
25 } mp_imagecodec_obj_t;
26 
imagecodec_obj_print(const mp_print_t * print,mp_obj_t self_in,mp_print_kind_t kind)27 void imagecodec_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind)
28 {
29     LOGD(LOG_TAG, "entern %s;\n", __func__);
30     mp_imagecodec_obj_t *self = MP_OBJ_TO_PTR(self_in);
31     mp_printf(print, "ModuleName(%s)", self->ModuleName);
32 }
33 
imagecodec_obj_make_new(const mp_obj_type_t * type,size_t n_args,size_t n_kw,const mp_obj_t * args)34 STATIC mp_obj_t imagecodec_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args)
35 {
36     LOGD(LOG_TAG, "entern  %s;\n", __func__);
37     mp_imagecodec_obj_t* driver_obj = m_new_obj(mp_imagecodec_obj_t);
38     if (!driver_obj) {
39         mp_raise_OSError(MP_EINVAL);
40     }
41 
42     driver_obj->Base.type = &minicv_imagecodec_type;
43     driver_obj->ModuleName = "minicv-ImageCodec";
44     driver_obj->mtype = CODEC_IMAGE_SOURCE_NONE;
45     driver_obj->mInstance = NULL;
46 
47     return MP_OBJ_FROM_PTR(driver_obj);
48 }
49 
obj_open(size_t n_args,const mp_obj_t * args)50 STATIC mp_obj_t obj_open(size_t n_args, const mp_obj_t *args)
51 {
52     LOGD(LOG_TAG, "entern  %s; n_args = %d;\n", __func__, n_args);
53     int ret = -1;
54     void* instance = NULL;
55     if (n_args < 2)
56     {
57         LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
58         return mp_const_none;
59     }
60     mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
61     mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self;
62     if (driver_obj == NULL)
63     {
64         LOGE(LOG_TAG, "driver_obj is NULL\n");
65         return mp_const_none;
66     }
67 
68     if (driver_obj->mInstance != NULL)
69     {
70         LOGE(LOG_TAG, "Module has been opened, please clode first\n");
71         return mp_const_none;
72     }
73 
74     driver_obj->mtype = (CodecImageType_t)mp_obj_get_int(args[1]);
75     LOGD(LOG_TAG, "%s:mtype = %d;\n", __func__, driver_obj->mtype);
76     instance = ImageCodecCreateInstance(driver_obj->mtype);
77     driver_obj->mInstance = instance;
78     if (instance == NULL)
79     {
80         LOGE(LOG_TAG, "ImageCodecCreateInstance failed\n");
81         return mp_const_none;
82     }
83 
84     LOGD(LOG_TAG, "%s:out\n", __func__);
85 
86     return mp_const_none;
87 }
88 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_open, 2, obj_open);
89 
obj_close(size_t n_args,const mp_obj_t * args)90 STATIC mp_obj_t obj_close(size_t n_args, const mp_obj_t *args)
91 {
92     LOGD(LOG_TAG, "entern  %s; n_args = %d;\n", __func__, n_args);
93     int ret = -1;
94     void* instance = NULL;
95     if (n_args < 1)
96     {
97         LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
98         return mp_const_none;
99     }
100     mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
101     mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self;
102     if (driver_obj == NULL)
103     {
104         LOGE(LOG_TAG, "driver_obj is NULL\n");
105         return mp_const_none;
106     }
107 
108     if (driver_obj->mInstance == NULL)
109     {
110         LOGE(LOG_TAG, "Module has not been opened, not need close\n");
111         return mp_const_none;
112     }
113 
114     ImageCodecDestoryInstance(driver_obj->mInstance);
115     driver_obj->mtype = CODEC_IMAGE_SOURCE_NONE;
116     driver_obj->mInstance = NULL;
117     LOGD(LOG_TAG, "%s:out\n", __func__);
118 
119     return mp_const_none;
120 }
121 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_close, 1, obj_close);
122 
obj_imgRead(size_t n_args,const mp_obj_t * args)123 STATIC mp_obj_t obj_imgRead(size_t n_args, const mp_obj_t *args)
124 {
125     LOGD(LOG_TAG, "entern  %s; n_args = %d;\n", __func__, n_args);
126     int ret = -1;
127     void* instance = NULL;
128     if (n_args < 2)
129     {
130         LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
131         return mp_const_none;
132     }
133     mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
134     mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self;
135     if (driver_obj == NULL)
136     {
137         LOGE(LOG_TAG, "driver_obj is NULL\n");
138         return mp_const_none;
139     }
140 
141     if (driver_obj->mInstance == NULL)
142     {
143         LOGE(LOG_TAG, "Module has been closed, please open first\n");
144         return mp_const_none;
145     }
146 
147     ImageBuffer_t *image = NULL;
148     char *mFileName = (char *)mp_obj_str_get_str(args[1]);
149     LOGD(LOG_TAG, "mFileName = %s;\n", mFileName);
150     ret = ImageCodecImgRead(driver_obj->mInstance, &image, mFileName);
151     if (ret != 0)
152     {
153         LOGE(LOG_TAG, "ImageCodecImgRead failed mFileName = %s;\n", mFileName);
154         return mp_const_none;
155     }
156     LOGD(LOG_TAG, "%s:out image->address[0] = %p;image = %p;\n", __func__, image->address[0], image);
157 
158     return MP_OBJ_FROM_PTR(image);
159 }
160 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgRead, 2, obj_imgRead);
161 
obj_imgReadMulti(size_t n_args,const mp_obj_t * args)162 STATIC mp_obj_t obj_imgReadMulti(size_t n_args, const mp_obj_t *args)
163 {
164     LOGD(LOG_TAG, "entern  %s; n_args = %d;\n", __func__, n_args);
165     int ret = -1;
166     void* instance = NULL;
167     if (n_args < 2)
168     {
169         LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
170         return mp_const_none;
171     }
172     mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
173     mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self;
174     if (driver_obj == NULL)
175     {
176         LOGE(LOG_TAG, "driver_obj is NULL\n");
177         return mp_const_none;
178     }
179 
180     if (driver_obj->mInstance == NULL)
181     {
182         LOGE(LOG_TAG, "Module has been closed, please open first\n");
183         return mp_const_none;
184     }
185 
186     ImageBuffer_t *image = NULL;
187     char *mFileName = (char *)mp_obj_str_get_str(args[1]);
188     LOGD(LOG_TAG, "mFileName = %s;\n", mFileName);
189     ret = ImageCodecImgRead(driver_obj->mInstance, &image, mFileName);
190     if (ret != 0)
191     {
192         LOGE(LOG_TAG, "ImageCodecImgRead failed mFileName = %s;\n", mFileName);
193         return mp_const_none;
194     }
195     LOGD(LOG_TAG, "%s:out image->address[0] = %p;image = %p;\n", __func__, image->address[0], image);
196 
197     return MP_OBJ_FROM_PTR(image);
198 }
199 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgReadMulti, 2, obj_imgReadMulti);
200 
obj_imgWrite(size_t n_args,const mp_obj_t * args)201 STATIC mp_obj_t obj_imgWrite(size_t n_args, const mp_obj_t *args)
202 {
203     LOGD(LOG_TAG, "entern  %s; n_args = %d;\n", __func__, n_args);
204     int ret = -1;
205     void* instance = NULL;
206     if (n_args < 3)
207     {
208         LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
209         return mp_const_none;
210     }
211     mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
212     mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self;
213     if (driver_obj == NULL)
214     {
215         LOGE(LOG_TAG, "driver_obj is NULL\n");
216         return mp_const_none;
217     }
218 
219     if (driver_obj->mInstance == NULL)
220     {
221         LOGE(LOG_TAG, "Module has been closed, please open first\n");
222         return mp_const_none;
223     }
224 
225     ImageBuffer_t *image = (ImageBuffer_t *)MP_OBJ_TO_PTR(args[1]);
226     char *mFileName = (char *)mp_obj_str_get_str(args[2]);
227     LOGD(LOG_TAG, "image = %p;\n", image);
228     LOGD(LOG_TAG, "mFileName = %s;\n", mFileName);
229     ret = ImageCodecImgWrite(driver_obj->mInstance, image, mFileName);
230     if (ret)
231     {
232         LOGE(LOG_TAG, "%s:ImageCodecImgWrite failed\n", __func__);
233     }
234     LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret);
235 
236     return mp_const_none;
237 }
238 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgWrite, 3, obj_imgWrite);
239 
obj_imgWriteMulti(size_t n_args,const mp_obj_t * args)240 STATIC mp_obj_t obj_imgWriteMulti(size_t n_args, const mp_obj_t *args)
241 {
242     LOGD(LOG_TAG, "entern  %s; n_args = %d;\n", __func__, n_args);
243     int ret = -1;
244     void* instance = NULL;
245     if (n_args < 3)
246     {
247         LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
248         return mp_const_none;
249     }
250     mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
251     mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self;
252     if (driver_obj == NULL)
253     {
254         LOGE(LOG_TAG, "driver_obj is NULL\n");
255         return mp_const_none;
256     }
257 
258     if (driver_obj->mInstance == NULL)
259     {
260         LOGE(LOG_TAG, "Module has been closed, please open first\n");
261         return mp_const_none;
262     }
263 
264     ImageBuffer_t **image = (ImageBuffer_t **)MP_OBJ_TO_PTR(args[1]);
265     char *mFileName = (char *)mp_obj_str_get_str(args[2]);
266     LOGD(LOG_TAG, "image = %p;\n", image);
267     LOGD(LOG_TAG, "mFileName = %s;\n", mFileName);
268     ret = ImageCodecImgWriteMulti(driver_obj->mInstance, image, mFileName);
269     if (ret)
270     {
271         LOGE(LOG_TAG, "%s:ImageCodecImgWriteMulti failed\n", __func__);
272     }
273     LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret);
274 
275     return mp_const_none;
276 }
277 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgWriteMulti, 3, obj_imgWriteMulti);
278 
obj_imgDecode(size_t n_args,const mp_obj_t * args)279 STATIC mp_obj_t obj_imgDecode(size_t n_args, const mp_obj_t *args)
280 {
281     LOGD(LOG_TAG, "entern  %s; n_args = %d;\n", __func__, n_args);
282     int ret = -1;
283     void* instance = NULL;
284     if (n_args < 3)
285     {
286         LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
287         return mp_const_none;
288     }
289     mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
290     mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self;
291     if (driver_obj == NULL)
292     {
293         LOGE(LOG_TAG, "driver_obj is NULL\n");
294         return mp_const_none;
295     }
296 
297     if (driver_obj->mInstance == NULL)
298     {
299         LOGE(LOG_TAG, "Module has been closed, please open first\n");
300         return mp_const_none;
301     }
302 
303     void *addr = (void *)MP_OBJ_TO_PTR(args[1]);
304     ImageBuffer_t **image = (ImageBuffer_t **)MP_OBJ_TO_PTR(args[2]);
305     LOGD(LOG_TAG, "addr = %p;\n", addr);
306     LOGD(LOG_TAG, "image = %p;\n", image);
307     ret = ImageCodecImgDecode(driver_obj->mInstance, addr, image);
308     if (ret)
309     {
310         LOGE(LOG_TAG, "%s:ImageCodecImgDecode failed\n", __func__);
311     }
312     LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret);
313 
314     return mp_const_none;
315 }
316 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgDecode, 3, obj_imgDecode);
317 
obj_imgDecode2(size_t n_args,const mp_obj_t * args)318 STATIC mp_obj_t obj_imgDecode2(size_t n_args, const mp_obj_t *args)
319 {
320     LOGD(LOG_TAG, "entern  %s; n_args = %d;\n", __func__, n_args);
321     int ret = -1;
322     void* instance = NULL;
323     if (n_args < 2)
324     {
325         LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
326         return mp_const_none;
327     }
328     mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
329     mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self;
330     if (driver_obj == NULL)
331     {
332         LOGE(LOG_TAG, "driver_obj is NULL\n");
333         return mp_const_none;
334     }
335 
336     if (driver_obj->mInstance == NULL)
337     {
338         LOGE(LOG_TAG, "Module has been closed, please open first\n");
339         return mp_const_none;
340     }
341 
342     char *mFileName = (char *)mp_obj_str_get_str(args[1]);
343     LOGD(LOG_TAG, "mFileName = %s;\n", mFileName);
344     ImageBuffer_t *image = ImageCodecImgDecode2(driver_obj->mInstance, mFileName);
345     if (image == NULL)
346     {
347         LOGE(LOG_TAG, "%s:ImageCodecImgDecode2 failed\n", __func__);
348     }
349     LOGD(LOG_TAG, "%s:out image = %p;\n", __func__, image);
350 
351     return MP_OBJ_FROM_PTR(image);
352 }
353 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgDecode2, 2, obj_imgDecode2);
354 
obj_imgEncode(size_t n_args,const mp_obj_t * args)355 STATIC mp_obj_t obj_imgEncode(size_t n_args, const mp_obj_t *args)
356 {
357     LOGD(LOG_TAG, "entern  %s; n_args = %d;\n", __func__, n_args);
358     int ret = -1;
359     void* instance = NULL;
360     if (n_args < 3)
361     {
362         LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
363         return mp_const_none;
364     }
365     mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
366     mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self;
367     if (driver_obj == NULL)
368     {
369         LOGE(LOG_TAG, "driver_obj is NULL\n");
370         return mp_const_none;
371     }
372 
373     if (driver_obj->mInstance == NULL)
374     {
375         LOGE(LOG_TAG, "Module has been closed, please open first\n");
376         return mp_const_none;
377     }
378 
379     void *addr = (void *)MP_OBJ_TO_PTR(args[1]);
380     ImageBuffer_t **image = (ImageBuffer_t **)MP_OBJ_TO_PTR(args[2]);
381     LOGD(LOG_TAG, "addr = %p;\n", addr);
382     LOGD(LOG_TAG, "image = %p;\n", image);
383     ret = ImageCodecImgEncode(driver_obj->mInstance, addr, image);
384     if (ret)
385     {
386         LOGE(LOG_TAG, "%s:ImageCodecImgEncode failed\n", __func__);
387     }
388     LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret);
389 
390     return mp_const_none;
391 }
392 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_imgEncode, 3, obj_imgEncode);
393 
obj_haveImageReader(size_t n_args,const mp_obj_t * args)394 STATIC mp_obj_t obj_haveImageReader(size_t n_args, const mp_obj_t *args)
395 {
396     LOGD(LOG_TAG, "entern  %s; n_args = %d;\n", __func__, n_args);
397     int ret = -1;
398     void* instance = NULL;
399     if (n_args < 2)
400     {
401         LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
402         return mp_const_none;
403     }
404     mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
405     mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self;
406     if (driver_obj == NULL)
407     {
408         LOGE(LOG_TAG, "driver_obj is NULL\n");
409         return mp_const_none;
410     }
411 
412     if (driver_obj->mInstance == NULL)
413     {
414         LOGE(LOG_TAG, "Module has been closed, please open first\n");
415         return mp_const_none;
416     }
417 
418     char *mFileName = (char *)mp_obj_str_get_str(args[1]);
419     LOGD(LOG_TAG, "mFileName = %s;\n", mFileName);
420     ret = ImageCodechaveImageReader(driver_obj->mInstance, mFileName);
421     if (ret)
422     {
423         LOGE(LOG_TAG, "%s:ImageCodechaveImageReader failed\n", __func__);
424     }
425     LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret);
426 
427     return mp_const_none;
428 }
429 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_haveImageReader, 2, obj_haveImageReader);
430 
obj_haveImageWriter(size_t n_args,const mp_obj_t * args)431 STATIC mp_obj_t obj_haveImageWriter(size_t n_args, const mp_obj_t *args)
432 {
433     LOGD(LOG_TAG, "entern  %s; n_args = %d;\n", __func__, n_args);
434     int ret = -1;
435     void* instance = NULL;
436     if (n_args < 2)
437     {
438         LOGE(LOG_TAG, "%s: args num is illegal :n_args = %d;\n", __func__, n_args);
439         return mp_const_none;
440     }
441     mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
442     mp_imagecodec_obj_t* driver_obj = (mp_imagecodec_obj_t *)self;
443     if (driver_obj == NULL)
444     {
445         LOGE(LOG_TAG, "driver_obj is NULL\n");
446         return mp_const_none;
447     }
448 
449     if (driver_obj->mInstance == NULL)
450     {
451         LOGE(LOG_TAG, "Module has been closed, please open first\n");
452         return mp_const_none;
453     }
454 
455     char *mFileName = (char *)mp_obj_str_get_str(args[1]);
456     LOGD(LOG_TAG, "mFileName = %s;\n", mFileName);
457     ret = ImageCodechaveImageWriter(driver_obj->mInstance, mFileName);
458     if (ret)
459     {
460         LOGE(LOG_TAG, "%s:ImageCodechaveImageWriter failed\n", __func__);
461     }
462     LOGD(LOG_TAG, "%s:out ret = %d;\n", __func__, ret);
463 
464     return mp_const_none;
465 }
466 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(imagecodec_obj_haveImageWriter, 2, obj_haveImageWriter);
467 
468 STATIC const mp_rom_map_elem_t imagecodec_locals_dict_table[] = {
469     {MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ImageCodec)},
470     {MP_OBJ_NEW_QSTR(MP_QSTR_CODEC_IMAGE_SOURCE_NONE), MP_ROM_INT(CODEC_IMAGE_SOURCE_NONE)},
471     {MP_OBJ_NEW_QSTR(MP_QSTR_CODEC_IMAG_SOURCE_IMAGE_PNG), MP_ROM_INT(CODEC_IMAG_SOURCE_IMAGE_PNG)},
472     {MP_OBJ_NEW_QSTR(MP_QSTR_CODEC_IMAG_SOURCE_IMAGE_JPG), MP_ROM_INT(CODEC_IMAG_SOURCE_IMAGE_JPG)},
473     {MP_OBJ_NEW_QSTR(MP_QSTR_CODEC_IMAG_SOURCE_IMAGE_BMP), MP_ROM_INT(CODEC_IMAG_SOURCE_IMAGE_BMP)},
474     {MP_OBJ_NEW_QSTR(MP_QSTR_CODEC_IMAG_SOURCE_IMAGE_GIF), MP_ROM_INT(CODEC_IMAG_SOURCE_IMAGE_GIF)},
475     {MP_OBJ_NEW_QSTR(MP_QSTR_CODEC_IMAG_SOURCE_MAX), MP_ROM_INT(CODEC_IMAG_SOURCE_MAX)},
476     {MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&imagecodec_obj_open)},
477     {MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&imagecodec_obj_close)},
478     {MP_ROM_QSTR(MP_QSTR_imgRead), MP_ROM_PTR(&imagecodec_obj_imgRead)},
479     {MP_ROM_QSTR(MP_QSTR_imgReadMulti), MP_ROM_PTR(&imagecodec_obj_imgReadMulti)},
480     {MP_ROM_QSTR(MP_QSTR_imgWrite), MP_ROM_PTR(&imagecodec_obj_imgWrite)},
481     {MP_ROM_QSTR(MP_QSTR_imgWriteMulti), MP_ROM_PTR(&imagecodec_obj_imgWriteMulti)},
482     {MP_ROM_QSTR(MP_QSTR_imgDecode), MP_ROM_PTR(&imagecodec_obj_imgDecode)},
483     {MP_ROM_QSTR(MP_QSTR_imgDecode2), MP_ROM_PTR(&imagecodec_obj_imgDecode2)},
484     {MP_ROM_QSTR(MP_QSTR_imgEncode), MP_ROM_PTR(&imagecodec_obj_imgEncode)},
485     {MP_ROM_QSTR(MP_QSTR_haveImageReader), MP_ROM_PTR(&imagecodec_obj_haveImageReader)},
486     {MP_ROM_QSTR(MP_QSTR_haveImageWriter), MP_ROM_PTR(&imagecodec_obj_haveImageWriter)},
487 };
488 
489 STATIC MP_DEFINE_CONST_DICT(imagecodec_locals_dict, imagecodec_locals_dict_table);
490 
491 const mp_obj_type_t minicv_imagecodec_type = {
492     .base = {&mp_type_type},
493     .name = MP_QSTR_ImageCodec,
494     .print = imagecodec_obj_print,
495     .make_new = imagecodec_obj_make_new,
496     .locals_dict = (mp_obj_dict_t *)&imagecodec_locals_dict,
497 };
498 
499