劳务公司网站建设,做公众号的网站模板下载,响应式高端网站,wordpress级验一、显示效果展示 二、OpenCV 4.5.0
OpenCV 4.5.0是OpenCV#xff08;Open Source Computer Vision Library#xff0c;开源计算机视觉库#xff09;的一个重要更新版本#xff0c;该版本在多个方面进行了优化和新增了多项功能。
三、ONNX模型
ONNX#xff08;Open Neu…一、显示效果展示 二、OpenCV 4.5.0
OpenCV 4.5.0是OpenCVOpen Source Computer Vision Library开源计算机视觉库的一个重要更新版本该版本在多个方面进行了优化和新增了多项功能。
三、ONNX模型
ONNXOpen Neural Network Exchange模型是一种针对机器学习所设计的开放式的文件格式用于存储训练好的模型。它允许不同的深度学习框架如PyTorch、TensorFlow、MXNet等之间交换和共享模型使得模型可以在不同平台和工具上进行部署和推理。
四、OpenCV加载onnx模型进行前向推理实现识别扑克牌识别
//统计预测的结果private int[] number_classnew int[54];public Bitmap detection(Bitmap bp){Canvas cannew Canvas();Paint pnew Paint();android.graphics.Bitmap.Config bitmapConfig bp.getConfig();bp bp.copy(bitmapConfig, true);cannew Canvas(bp);p.setAntiAlias(true);//不填充默认填充p.setStyle(Paint.Style.STROKE);//设置线条宽度p.setStrokeWidth(5);//设置颜色p.setColor(0xFF33FFFF);p.setTextAlign(Paint.Align.LEFT);p.setTextSize(50);Mat blob Dnn.blobFromImage(src, IN_SCALE_FACTOR,new Size(IN_WIDTH, IN_HEIGHT),new Scalar(MEAN_VAL, MEAN_VAL, MEAN_VAL), false);net.setInput(blob);blob.release();//获取输出层的名字ListString outnamesnet.getUnconnectedOutLayersNames();
// Log.i(aa,String.valueOf(outnames));//创建输出矩阵集合ListMat detections new ArrayListMat();net.forward(detections,outnames);//获取输出的盒子和置信度Mat scoresdetections.get(0);Mat boxes detections.get(1);scores scores.reshape(1,3000).colRange(1,55);boxes boxes.reshape(1,3000);Size ssscores.size();
// Log.i(aa,String.valueOf(scores));
// Log.i(aa,String.valueOf(boxes));ListRect2d rect2dListnew ArrayList();//box信息ListFloat confListnew ArrayList();//置信度ListInteger objIndexListnew ArrayList();//对象类别索引for(int i0; iscores.rows();i){Mat one_rowscores.rowRange(i,i1);Core.MinMaxLocResult max_indexCore.minMaxLoc(one_row);double max_valuemax_index.maxVal;Point locationmax_index.maxLoc;if(max_value0.4){confList.add((float) max_value);objIndexList.add((int)location.x);Mat box_oneboxes.rowRange(i,i1);float[] aanew float[4];box_one.get(0,0,aa);double x1aa[0];double y1aa[1];double x2aa[2];double y2aa[3];rect2dList.add(new Rect2d(x1,y1,x2,y2));}}//去重//去重后的索引值MatOfInt indexnew MatOfInt();//转换box的结果集MatOfRect2d boxenew MatOfRect2d(rect2dList.toArray(new Rect2d[0]));//转换置信度结果集float[] confArrnew float[confList.size()];for(int j0;jconfList.size();j){confArr[j]confList.get(j);}MatOfFloat connew MatOfFloat(confArr);//使用nms去重Dnn.NMSBoxes(boxe,con,0.4f,0.45f,index);if (index.empty()){return bp;}//画框int[] intsindex.toArray();for(int x:ints){
// Log.i(aa,String.valueOf(x));double[] aanew double[4];boxe.get(x,0,aa);//Log.i(aa,String.valueOf(aa[0]));//Imgproc.rectangle(src,new Point(aa[0]*src.width(),aa[1]*src.height()-70),new Point(aa[2]*src.width()200,aa[1]*src.height()),new Scalar(255,255,255),-1);//Imgproc.rectangle(src,new Point(aa[0]*src.width(),aa[1]*src.height()),new Point(aa[2]*src.width(),aa[3]*src.height()),new Scalar(255,255,0),10);//Imgproc.putText(src,classNames[objIndexList.get(x)]:confList.get(x),new Point(aa[0]*src.width(),aa[1]*src.height()),Imgproc.FONT_HERSHEY_SIMPLEX, 3, new Scalar(0, 0, 0));//画框can.drawRect((float) aa[0]*src.width(),(float) aa[1]*src.height(),(float)aa[2]*src.width(),(float)aa[3]*src.height(),p);//绘制填充框p.setStyle(Paint.Style.FILL);p.setColor(0xFFFFCC00);can.drawRect((float) aa[0]*src.width(),(float) aa[1]*src.height()-60,(float)aa[2]*src.width()150,(float)aa[1]*src.height(),p);//写字p.setColor(0xFFFF0000);can.drawText(classNames[objIndexList.get(x)]: String.format(%.3f, confList.get(x)),(float)aa[0]*src.width(),(float) aa[1]*src.height()-10,p);p.setStyle(Paint.Style.STROKE);p.setColor(0xFF33FFFF);//统计类别信息number_class[objIndexList.get(x)]1;}
五、完整源码下载
Card.zip: https://url83.ctfile.com/f/45573183-1373015108-43a4dd?p7526 (访问密码: 7526)