Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
[0.5.4] fix freetype & r329 nn & fix rgba && remove orb.
Browse files Browse the repository at this point in the history
  • Loading branch information
junhuanchen committed Feb 24, 2023
1 parent b5e3901 commit c6b5c41
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 37 deletions.
2 changes: 1 addition & 1 deletion docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ your v83x

- python3.8 setup.py bdist_wheel maix_v83x

- rm dist/* && python3.8 setup.py clean --all bdist_wheel maix_v83x && adb shell 'rm /root/maixpy3-0.5.*-cp38-cp38-linux_armv7l.whl' && adb push ./dist/maixpy3-0.5.*-cp38-cp38-linux_armv7l.whl /root/ && adb shell "pip install /root/maixpy3-0.5.*-cp38-cp38-linux_armv7l.whl --upgrade"
- rm -rf dist/* && python3.8 setup.py clean --all bdist_wheel maix_v83x && adb shell 'rm /root/maixpy3-0.5.*-cp38-cp38-linux_armv7l.whl' && adb push ./dist/maixpy3-0.5.*-cp38-cp38-linux_armv7l.whl /root/ && adb shell "pip install /root/maixpy3-0.5.*-cp38-cp38-linux_armv7l.whl --upgrade"

- adb shell 'rm /root/maixpy3-0.5.*-cp38-cp38-linux_armv7l.whl' && adb push ./dist/maixpy3-0.5.*-cp38-cp38-linux_armv7l.whl /root/ && adb shell "pip install /root/maixpy3-0.5.*-cp38-cp38-linux_armv7l.whl --upgrade"

Expand Down
2 changes: 1 addition & 1 deletion envs/linux_desktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
get_srcs('ext_modules/libmaix/components/libmaix/lib/arch/desktop/libmaix_disp') +
get_srcs('ext_modules/_maix_display'),
libraries=[
"opencv_videoio", "opencv_highgui", "opencv_core", "opencv_imgproc", "opencv_imgcodecs", "opencv_freetype"
"opencv_core", "opencv_imgproc", "opencv_imgcodecs", "opencv_freetype"
],
library_dirs=[
"/usr/lib/",
Expand Down
9 changes: 5 additions & 4 deletions envs/maix_r329.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
get_srcs('ext_modules/libmaix/components/maix_cv_image/src') +
get_srcs('ext_modules/libmaix/components/third_party/imlib/src'),
libraries=[
"maix_image","maix_disp", "opencv_videoio", "opencv_highgui", "opencv_core", "opencv_imgproc", "opencv_imgcodecs", "opencv_freetype", "opencv_flann", "opencv_features2d", "opencv_calib3d"
"maix_image","maix_disp",
"opencv_core", "opencv_imgproc", "opencv_imgcodecs", "opencv_freetype"
# "opencv_videoio", "opencv_highgui", "opencv_flann", "opencv_features2d", "opencv_calib3d"
],
library_dirs=["./ext_modules/libmaix/components/libmaix/lib/arch/r329/opencv4",
ext_so,
Expand Down Expand Up @@ -88,11 +90,10 @@
],
)

max_nn_srcs = get_srcs('ext_modules/_maix_nn_mdsc/src')
max_nn_srcs = get_srcs('ext_modules/_maix_nn_mud/src')
max_nn_srcs.extend(get_srcs('ext_modules/libmaix/components/libmaix/src'))
max_nn_srcs.remove("ext_modules/libmaix/components/libmaix/src/libmaix.c")
_maix_nn_module = Extension('_maix_nn',
include_dirs=['ext_modules/_maix_nn_mdsc/include', 'ext_modules/libmaix/components/libmaix/include'],
_maix_nn_module = Extension('_maix_nn', include_dirs=['ext_modules/_maix_nn_mud/include', 'ext_modules/libmaix/components/libmaix/include'],
sources=max_nn_srcs,
libraries=[
"maix_utils", "maix_cam", "maix_nn", "maix_nn_app"
Expand Down
17 changes: 10 additions & 7 deletions envs/maix_v83x.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
library_dirs=[ ext_so, ],
extra_link_args=[
"-Wl,-rpath=/usr/lib/python3.8/site-packages/maix"],
extra_compile_args=['-march=armv7-a', '-mfloat-abi=hard', '-mfpu=neon','-std=c++11', '-std=gnu++11' ],
# define_macros=[('V831Camera', None)],
)

Expand Down Expand Up @@ -112,7 +113,7 @@
"maix_disp",
],
library_dirs=["/lib", "/usr/lib", ext_so, ],
# extra_compile_args=['-DV83xDisplay'],
extra_compile_args=[],
extra_link_args=["-Wl,-rpath=/usr/lib/python3.8/site-packages/maix"]
)

Expand Down Expand Up @@ -152,6 +153,7 @@
"maix_utils", "maix_nn", "maix_cam",
],
library_dirs=[ ext_so, ],
extra_compile_args=['-march=armv7-a', '-mfloat-abi=hard', '-mfpu=neon', ],
# extra_link_args = [ "-Wl,-z,origin", "-Wl,-rpath='$ORIGIN/maix'" ]
extra_link_args=["-Wl,-rpath=/usr/lib/python3.8/site-packages/maix"]
)
Expand All @@ -166,7 +168,7 @@
"maix_nn",
],
library_dirs=[ ext_so, ],
# extra_compile_args=['-std=c++11', '-std=gnu++11', '-DCONFIG_ARCH_V831'],
extra_compile_args=['-std=c++11', '-std=gnu++11', '-DCONFIG_ARCH_V831'],
extra_link_args=["-Wl,-rpath=/usr/lib/python3.8/site-packages/maix"]
)

Expand All @@ -180,7 +182,7 @@
"maix_nn",
],
library_dirs=[ ext_so, ],
# extra_compile_args=['-std=c++11', '-std=gnu++11', '-DCONFIG_ARCH_V831'],
extra_compile_args=['-march=armv7-a', '-mfloat-abi=hard', '-mfpu=neon','-std=c++11', '-std=gnu++11', '-DCONFIG_ARCH_V831'],
extra_link_args=["-Wl,-rpath=/usr/lib/python3.8/site-packages/maix"]
)

Expand All @@ -194,7 +196,7 @@
"maix_nn",
],
library_dirs=[ ext_so, ],
# extra_compile_args=['-std=c++11', '-std=gnu++11', '-DCONFIG_ARCH_V831'],
extra_compile_args=['-march=armv7-a', '-mfloat-abi=hard', '-mfpu=neon','-std=c++11', '-std=gnu++11', '-DCONFIG_ARCH_V831'],
extra_link_args=["-Wl,-rpath=/usr/lib/python3.8/site-packages/maix"]
)

Expand Down Expand Up @@ -239,7 +241,8 @@
get_srcs('ext_modules/libmaix/components/third_party/imlib/src'),
libraries=[
"maix_utils", "maix_cam", "maix_image",
"opencv_videoio", "opencv_highgui", "opencv_core", "opencv_imgproc", "opencv_imgcodecs", "opencv_freetype", "opencv_flann", "opencv_features2d", "opencv_calib3d"
"opencv_core", "opencv_imgproc", "opencv_imgcodecs", "opencv_freetype"
# "opencv_videoio", "opencv_highgui", "opencv_flann", "opencv_features2d", "opencv_calib3d"
],
library_dirs=[
ext_so,
Expand All @@ -249,7 +252,7 @@
"-Wl,-rpath=/usr/lib/python3.8/site-packages/maix",
"-Wl,-rpath=/usr/lib/python3.8/site-packages"
],
extra_compile_args=['-std=c++11', '-std=gnu++11', '-DCONFIG_ARCH_V831', '-DIMLIB_CONFIG_H_FILE="costom_imlib_config.h"' ],
extra_compile_args=['-march=armv7-a', '-mfloat-abi=hard', '-mfpu=neon','-std=c++11', '-std=gnu++11', '-DCONFIG_ARCH_V831', '-DIMLIB_CONFIG_H_FILE="costom_imlib_config.h"' ],
)

_maix_modules = [
Expand All @@ -259,7 +262,7 @@
_maix_image_module,
# _maix_camera_module,
_maix_speech_module,
_maix_display_module,
# _maix_display_module,
_maix_nn_module,
_maix_nn_decode_retinaface_module,
_maix_nn_decode_license_plate_location_module,
Expand Down
12 changes: 6 additions & 6 deletions ext_modules/_maix_image/_maix_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ maix_image &maix_image::_new(std::vector<int> size, std::vector<int> color, std:
this->_img = libmaix_image_create_patch(this->_img, size[0], size[1], any_cast<libmaix_image_mode_t>(this->py_to_pram[this->get_to(this->_maix_image_type)][0]), LIBMAIX_IMAGE_LAYOUT_HWC, NULL, true);
if (this->_img)
{
libmaix_cv_image_draw_rectangle(this->_img, 0, 0, size[0], size[1], MaixColor(color[0], color[1], color[2]), -1);
libmaix_cv_image_draw_rectangle(this->_img, 0, 0, size[0], size[1], MaixColorBGRA(color[0], color[1], color[2], color[3]), -1);
}
else
{
Expand Down Expand Up @@ -555,7 +555,7 @@ maix_image &maix_image::_draw_line(int x1, int y1, int x2, int y2, std::vector<i
py::print("[image] is empty !");
return *this;
}
libmaix_cv_image_draw_line(this->_img, x1, y1, x2, y2, MaixColor(color[0], color[1], color[2]), thickness);
libmaix_cv_image_draw_line(this->_img, x1, y1, x2, y2, MaixColorBGRA(color[0], color[1], color[2], color[3]), thickness);
return *this;
}

Expand Down Expand Up @@ -584,7 +584,7 @@ maix_image &maix_image::_draw_rectangle(int x1_x, int y1_y, int x2_w, int y2_h,
}
if (is_xywh)
x2_w = x1_x + x2_w, y2_h = y1_y + y2_h;
libmaix_cv_image_draw_rectangle(this->_img, x1_x, y1_y, x2_w, y2_h, MaixColor(color[0], color[1], color[2]), thickness);
libmaix_cv_image_draw_rectangle(this->_img, x1_x, y1_y, x2_w, y2_h, MaixColorBGRA(color[0], color[1], color[2], color[3]), thickness);
return *this;
}

Expand All @@ -595,7 +595,7 @@ maix_image &maix_image::_draw_circle(int x, int y, int r, std::vector<int> color
py::print("[image] is empty !");
return *this;
}
libmaix_cv_image_draw_circle(this->_img, x, y, r, MaixColor(color[0], color[1], color[2]), thickness);
libmaix_cv_image_draw_circle(this->_img, x, y, r, MaixColorBGRA(color[0], color[1], color[2], color[3]), thickness);
return *this;
}

Expand All @@ -606,7 +606,7 @@ maix_image &maix_image::_draw_ellipse(int cx, int cy, int rx, int ry, double ang
py::print("[image] is empty !");
return *this;
}
libmaix_cv_image_draw_ellipse(this->_img, cx, cy, rx, ry, angle, startAngle, endAngle, MaixColor(color[0], color[1], color[2]), thickness);
libmaix_cv_image_draw_ellipse(this->_img, cx, cy, rx, ry, angle, startAngle, endAngle, MaixColorBGRA(color[0], color[1], color[2], color[3]), thickness);
return *this;
}

Expand All @@ -617,7 +617,7 @@ maix_image &maix_image::_draw_string(int x, int y, std::string str, double scale
py::print("[image] is empty !");
return *this;
}
libmaix_cv_image_draw_string(this->_img, x, y, str.c_str(), scale, MaixColor(color[0], color[1], color[2]), thickness);
libmaix_cv_image_draw_string(this->_img, x, y, str.c_str(), scale, MaixColorBGRA(color[0], color[1], color[2], color[3]), thickness);
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion ext_modules/_maix_image/include/costom_imlib_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ extern "C"
// FB Heap Block Size
#define OMV_UMM_BLOCK_SIZE 256

#define OMV_FB_ALLOC_SIZE (4 * 1024 * 1024) // minimum fb alloc size
#define OMV_FB_ALLOC_SIZE (2 * 1024 * 1024) // minimum fb alloc size

// Enable STM32 DMA2D
// #define IMLIB_ENABLE_DMA2D
Expand Down
2 changes: 1 addition & 1 deletion ext_modules/_maix_image/include/cv_orb.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef cv_orb_hpp
#define cv_orb_hpp
// #define cv_orb_hpp

#include "maix_image.h"

Expand Down
4 changes: 2 additions & 2 deletions ext_modules/_maix_image/include/maix_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include "libmaix_cv_image.h"
#include "libmaix_disp.h"

#define enable_PIL
#define enable_numpy
// #define enable_PIL
// #define enable_numpy

namespace py = pybind11;
typedef enum
Expand Down
11 changes: 6 additions & 5 deletions ext_modules/_maix_image/py_maix_image.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "maix_image.h"

#include "cv_orb.hpp"
// #include "cv_orb.hpp"

void _load_freetype(std::string path, int fontHeight)
{
Expand Down Expand Up @@ -155,8 +155,9 @@ PYBIND11_MODULE(_maix_image, mo)
.def("find_template", &maix_image::_imlib_find_template, py::arg("template") = maix_image(), py::arg("thresh") = 0.5, py::arg("roi") = std::vector<int>{0, 0, 0, 0}, py::arg("step") = 2, py::arg("search") = 1)
.def("find_barcodes", &maix_image::_imlib_find_barcodes, py::arg("roi") = std::vector<int>{0, 0, 0, 0}); // module end

pybind11::class_<cv_orb>(mo, "orb")
.def(pybind11::init<int, float, int, int, int, int, int, int, int>(),
py::arg("nfeatures") = 500, py::arg("scaleFactor") = 1.2f, py::arg("nlevels") = 8, py::arg("edgeThreshold") = 31, py::arg("firstLevel") = 0, py::arg("WTA_K") = 2, py::arg("scoreType") = 0, py::arg("patchSize") = 31, py::arg("fastThreshold") = 20)
.def("match", &cv_orb::match, pybind11::arg("src"), pybind11::arg("dst"), pybind11::arg("limit") = 30, pybind11::arg("min") = 0.0f, pybind11::arg("max") = 100.f, pybind11::arg("crossCheck") = false, pybind11::arg("dump") = 0);
// pybind11::class_<cv_orb>(mo, "orb")
// .def(pybind11::init<int, float, int, int, int, int, int, int, int>(),
// py::arg("nfeatures") = 500, py::arg("scaleFactor") = 1.2f, py::arg("nlevels") = 8, py::arg("edgeThreshold") = 31, py::arg("firstLevel") = 0, py::arg("WTA_K") = 2, py::arg("scoreType") = 0, py::arg("patchSize") = 31, py::arg("fastThreshold") = 20)
// .def("match", &cv_orb::match, pybind11::arg("src"), pybind11::arg("dst"), pybind11::arg("limit") = 30, pybind11::arg("min") = 0.0f, pybind11::arg("max") = 100.f, pybind11::arg("crossCheck") = false, pybind11::arg("dump") = 0);

}
9 changes: 5 additions & 4 deletions ext_modules/_maix_vivo/_maix_vivo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ class _v83x_vivo
uint32_t *argb = (uint32_t *)ui->buf, *abgr = (uint32_t *)value.c_str();
for (int i = 0, sum = frame_size; i != sum; i++)
{
argb[i] = (abgr[i] & 0xFF000000) | // ______AA
((abgr[i] & 0x00FF0000) >> 16) | // BB______
(abgr[i] & 0x0000FF00) | // __GG____
((abgr[i] & 0x000000FF) << 16); // ____RR__
argb[i] = __builtin_bswap32(argb[i]);
// argb[i] = (abgr[i] & 0xFF000000) | // ______AA
// ((abgr[i] & 0x00FF0000) >> 16) | // BB______
// (abgr[i] & 0x0000FF00) | // __GG____
// ((abgr[i] & 0x000000FF) << 16); // ____RR__
}
}
else if (frame_size * 3 == value.length())
Expand Down
2 changes: 1 addition & 1 deletion ext_modules/libmaix
Submodule libmaix updated 113 files
2 changes: 1 addition & 1 deletion maix/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

version='0.5.3'
version='0.5.4'

__all__ = ['display', 'camera', 'image']

Expand Down
2 changes: 1 addition & 1 deletion maix/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def close(self):
try:
try:
# use mpp vivo on v831
from maix import display, image
from maix import display
from _maix_vivo import _v83x_vivo
class V831VivoMaixVideo(MaixVideo):
def __init__(self, source="allwinner mpp"):
Expand Down
9 changes: 7 additions & 2 deletions maix/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ def __draw__(img):
global __show__, _width, _height
if isinstance(img, bytes):
__show__.draw(img, _width, _height)
from maix import camera
except ModuleNotFoundError as e:
pass
# v83x remove _maix_display and dts get lcd size
import os
os.system("cat /sys/firmware/devicetree/base/soc@03000000/board/lcd > /tmp/lcd")
with open("/tmp/lcd", "r") as f:
lcd = f.read().strip()
if lcd.find("240,320") != -1:
config(size=(240, 320))
except Exception as e:
pass

Expand Down

0 comments on commit c6b5c41

Please sign in to comment.