Package: ax-pipeline-api
what this ?This project is a Python implementation ofax-pipeline.pip3 install ax-pipeline-api -UBased on AX620A Debian11 system. Docs atwiki.sipeed.com/m3axpiPython apis for pybind11 and ctypes are implemented here, but please do not mix them as there is only one screen and one camera.pybind11 has a friendlier usagectypes have a more stable effectnew pybind11 code (1.0.9+)It need update debian11(202202+) for pillow ImageFont(freetype). (sudo apt install libxft-dev && pip3 uninstall pillow -y && pip3 install pillow --no-cache-dir -U)https://user-images.githubusercontent.com/32978053/218361047-6a72b294-cd66-4f0e-8bed-152a6661d458.mp4The new API is still in an unstable state, so don't mind if you encounter strange bugs.importm3axpi# m3axpi.camera(SysCase=0) # switch os04a10# m3axpi.camera(SysCase=2) # default gc4653# m3axpi.load("/home/config/yolov8.json")fromPILimportImage,ImageDraw,ImageFontlcd_width,lcd_height,lcd_channel=854,480,4fnt=ImageFont.truetype("/home/res/sans.ttf",20)img=Image.new('RGBA',(lcd_width,lcd_height),(255,0,0,200))ui=ImageDraw.ImageDraw(img)ui.rectangle((20,20,lcd_width-20,lcd_height-20),fill=(0,0,0,0),outline=(0,0,255,100),width=20)logo=Image.open("/home/res/logo.png")img.paste(logo,box=(lcd_width-logo.size[0],lcd_height-logo.size[1]),mask=None)whileTrue:rgba=img.copy()tmp=m3axpi.capture()rgb=Image.frombuffer("RGB",(tmp[1],tmp[0]),tmp[3])rgba.paste(rgb,box=(0,0),mask=None)## camera 320x180 paste 854x480res=m3axpi.forward()if'nObjSize'inres:ui=ImageDraw.ImageDraw(rgba)ui.text((0,0),"fps:%02d"%(res['niFps']),font=fnt)forobjinres['mObjects']:x,y,w,h=int(obj['bbox'][0]*lcd_width),int(obj['bbox'][1]*lcd_height),int(obj['bbox'][2]*lcd_width),int(obj['bbox'][3]*lcd_height)ui.rectangle((x,y,x+w,y+h),fill=(255,0,0,100),outline=(255,0,0,255))ui.text((x,y),"%s:%02d"%(obj['objname'],obj['prob']*100),font=fnt)rgba.paste(logo,box=(x+w-logo.size[1],y+h-logo.size[1]),mask=None)m3axpi.display([lcd_height,lcd_width,lcd_channel,rgba.tobytes()])tests/test_m3axpi_module.pyold ctypes codeyolov5shttps://user-images.githubusercontent.com/32978053/204093040-179e35d0-8bfa-4626-b4cc-46f3f148eb71.mp4importtimefromaximportpipelinepipeline.load(['libsample_vin_ivps_joint_vo_sipy.so','-p','/home/config/yolov5s.json','-c','2',])whilepipeline.work():time.sleep(0.001)tmp=pipeline.result()iftmpandtmp['nObjSize']:foriintmp['mObjects']:x,y,w,h=i['bbox']['x'],i['bbox']['y'],i['bbox']['w'],i['bbox']['h']objname,objprob=i['objname'],i['prob']print(objname,objprob,x,y,w,h)# if tmp['nObjSize'] > 10: # try exit#     pipeline.drop()pipeline.drop()yolov5s_facehttps://user-images.githubusercontent.com/32978053/204444795-635299e9-89f1-4c76-9536-1c6dd9915b72.mp4importtimefromaximportpipelinepipeline.load(['libsample_vin_ivps_joint_vo_sipy.so','-p','/home/config/yolov5s_face.json','-c','2',])whilepipeline.work():time.sleep(0.001)tmp=pipeline.result()iftmpandtmp['nObjSize']:foriintmp['mObjects']:print(i)# if tmp['nObjSize'] > 10: # try exit#     pipeline.drop()pipeline.drop()other demotests/test_yolov5s_pillow.pyhttps://user-images.githubusercontent.com/32978053/204150061-779c2443-5416-4a5e-a10f-e684a035510d.mp4tests/test_ax_pose_print.pyhttps://user-images.githubusercontent.com/32978053/204150065-6977de65-423a-4895-a970-59ef914f9184.mp4more ?change sensorcamera os04a10 is'-c', '0',and gc4653 is'-c', '2',.pipeline.load(['libsample_vin_ivps_joint_vo_sipy.so','-p','/home/config/ax_pose.json','-c','0',])change libxxx*.sopipeline.load(['libsample_vin_ivps_joint_venc_rtsp_vo_sipy.so','-p','/home/config/yolov5_seg.json','-c','0',])Package with many inputs and outputslibsample_h264_ivps_joint_vo_sipy.so# input h264 video to ivps joint output screen volibsample_v4l2_user_ivps_joint_vo_sipy.so# input v4l2 /dev/videoX to ivps joint output screen volibsample_rtsp_ivps_joint_rtsp_vo_sipy.so# input video from rtsp to ivps joint output rtsp and screen volibsample_vin_ivps_joint_vo_sipy.so# input mipi sensor to ivps joint output screen volibsample_vin_ivps_joint_venc_rtsp_sipy.so# input mipi sensor to ivps joint output rtsplibsample_vin_ivps_joint_venc_rtsp_vo_sipy.so# input mipi sensor to ivps joint output rtsp and screen volibsample_vin_ivps_joint_vo_h265_sipy.so# input mipi sensor to ivps joint output screen vo and save h265 video filelibsample_multi_rtsp_ivps_joint_multi_rtsp_sipy.so# input multi rtsp video to ivps joint output multi rtsp videolibsample_rtsp_ivps_joint_rtsp_sipy.so# input video from rtsp to ivps joint output rtsplibsample_rtsp_ivps_joint_rtsp_vo_sipy.so# input video from rtsp to ivps joint output rtsp and screen volibsample_rtsp_ivps_joint_vo_sipy.so# input video from rtsp to ivps joint output screen vochange ai modelpipeline.load(['libsample_vin_ivps_joint_vo_sipy.so','-p','/home/config/yolov5s_face.json','-c','0',])In-system models on /home/config.ax_bvc_det.jsonhrnet_pose_yolov8.jsonyolov5s_face_recognition.json
ax_person_det.jsonlicense_plate_recognition.jsonyolov5s_license_plate.json
ax_pose.jsonnanodet.jsonyolov6.json
ax_pose_yolov5s.jsonpalm_hand_detection.jsonyolov7.json
ax_pose_yolov8.jsonpp_human_seg.jsonyolov7_face.json
crowdcount.jsonscrfd.jsonyolov7_palm_hand.json
hand_pose.jsonyolo_fastbody.jsonyolov8.json
hand_pose_yolov7_palm.jsonyolopv2.jsonyolov8_seg.json
hrnet_animal_pose.jsonyolov5_seg.jsonyolox.json
hrnet_pose.jsonyolov5s.json
hrnet_pose_ax_det.jsonyolov5s_face.jsonpypipython3 setup.py sdistpython3 setup.py build && cp build/lib*/m3axpi.*.so m3axpi.sorm -rf build && pip3 uninstall ax-pipeline-api -y && python3 setup.py build && pip3 install .pip3 install twinetwine upload dist/* --verbose