English | 中文
#include "maix_nn.hpp"
#include "maix_camera.hpp"
#include "maix_display.hpp"
int main()
{
nn::Classifier classifier("/root/models/mobilenetv2.mud");
image::Size input_size = classifier.input_size();
camera::Camera cam = camera::Camera(input_size.width(), input_size.height(), classifier.input_format());
display::Display disp = display::Display();
char msg[64];
while(!app::need_exit())
{
image::Image *img = cam.read();
auto *result = classifier.classify(*img);
int max_idx = result->at(0).first;
float max_score = result->at(0).second;
snprintf(msg, sizeof(msg), "%5.2f: %s", max_score, classifier.labels[max_idx].c_str());
img->draw_string(10, 10, msg, image::COLOR_RED);
disp.show(*img);
delete result;
delete img;
}
return 0;
}
from maix import camera, display, image, nn
classifier = nn.Classifier(model="/root/models/mobilenetv2.mud")
cam = camera.Camera(classifier.input_width(), classifier.input_height(), classifier.input_format())
disp = display.Display()
while 1:
img = cam.read()
res = classifier.classify(img)
max_idx, max_prob = res[0]
msg = f"{max_prob:5.2f}: {classifier.labels[max_idx]}"
img.draw_string(10, 10, msg, image.COLOR_RED)
disp.show(img)
只需添加注释,即可在 MaixPy 中使用此 API!
Python 示例代码:
from maix import uart
devices = uart.list_devices()
print(devices)
MaixCDK 在 maix_uart.hpp
中的实现:
namespace maix::uart {
/**
* List all UART devices can be directly used.
* @return All device path, list type, element is string type
* @maixpy maix.uart.list_devices
*/
std::vector<std::string> list_devices();
}
无需 AI 专业知识或昂贵的训练设备,一键训练模型,一键部署到 MaixCAM。
社区 | 地址 |
---|---|
MaixCDK 文档 | MaixCDK 文档 |
MaixPy 文档 | MaixPy 文档 |
应用商店 | maixhub.com/app |
项目分享 | maixhub.com/share |
Bilibili | 在 Bilibili 上搜索 MaixCAM 或 MaixPy |
讨论 | maixhub.com/discussion |
MaixCDK 问题 | github.com/sipeed/MaixPy/issues |
Telegram | t.me/maixpy |
QQ 群 | 862340358 |