日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

调试4

發布時間:2025/3/17 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 调试4 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 % 可調參數 3 %{ 4 test_path='C:\Users\cong\Desktop\研一實戰\項目\圖像中時間數字識別\OCR\one\3.jpg'; 5 neighbour_pixels_affect=3; 6 target_digit=2; 7 % forestTrain()參數設置 8 % .M - [1] number of trees to train 9 % .H - [max(hs)] number of classes 10 % .N1 - [5*N/M] number of data points for training each tree 11 % .F1 - [sqrt(F)] number features to sample for each node split 12 % .split - ['gini'] options include 'gini', 'entropy' and 'twoing' 13 % .minCount - [1] minimum number of data points to allow split 14 % .minChild - [1] minimum number of data points allowed at child nodes 15 % .maxDepth - [64] maximum depth of tree 16 % .dWts - [] weights used for sampling and weighing each data point 17 % .fWts - [] weights used for sampling features 18 % .discretize - [] optional function mapping structured to class labels 19 % format: [hsClass,hBest] = discretize(hsStructured,H); 20 varargin.M=1000; 21 %varargin.H=10; 22 23 % forestApply()的輸入設置 24 % data - [NxF] N length F feature vectors 25 % forest - learned forest classification model 26 % maxDepth - [] maximum depth of tree 27 % minCount - [] minimum number of data points to allow split 28 % best - [0] if true use single best prediction per tree 29 30 % forestApply()輸出結果及對比的閥值 31 % hs - [Nx1] predicted output labels 32 % ps - [NxH] predicted output label probabilities 33 ps_val_more_than0_3=0.2; 34 35 %滑窗檢測,窗口尺度,步長 36 win_h=20; 37 win_w=20; 38 step=1; 39 disp('參數配置成功...'); 40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 41 disp('正在讀入圖片及特征提取...'); 42 %讀入圖片及特征提取 43 data=[]; 44 label=[]; 45 temp_r1=0; 46 temp_c1=0; 47 48 for i_digit=0:10 49 % if(i_digit==target_digit) %%%%%%%%%%%%%%%%%%%%%% 50 % this_image_label=1; 51 % end 52 %數字轉字符 53 str=num2str(i_digit); %%數據是不是不平衡 54 path_temp=strcat('C:\Users\cong\Desktop\研一實戰\項目\圖像中時間數字識別\trainingSample\num',str,'\'); 55 file=dir(path_temp); 56 for i=3:length(file) 57 path= strcat(path_temp,file(i).name); 58 59 %%%%%%%%%%%%%%%%%%%%%%%%%% 60 % 加載圖片 61 %%%%%%%%%%%%%%%%%%%%%%%%%% 62 I=imread(path); 63 %I=imread('E:/WeChat.jpg'); 64 %%%%%%%%%%%%%%%%%%%%%%%%%% 65 % 提取channel features 66 %%%%%%%%%%%%%%%%%%%%%%%%%% 67 [all_channel_difference_features,temp_r1,temp_c1]=extract_features(I,neighbour_pixels_affect,1); 68 data=[data,all_channel_difference_features]; 69 label=[label;i_digit+1]; 70 if(rem(i,200)==0) 71 disp('...'); 72 end 73 end % for i=3:length(file) 74 disp('數字') 75 i_digit 76 disp('的特征提取完畢...'); 77 end % for i_digit=0:9 78 disp('讀入圖片及特征提取完畢...'); 79 %%%%%%%%%%%%%%%%%%%%%%%%%% 80 % 扔進分類器中,訓練 81 %%%%%%%%%%%%%%%%%%%%%%%%%% 82 data=data'; 83 disp('正在訓練,請稍等...'); 84 forest = forestTrain( data, label, varargin ); 85 disp('訓練完畢...'); 86 %} 87 %%%%%%%%%%%%%%%%%%%%%%%%%% 88 % 檢測,測試 89 test_label=[]; 90 test_label_p=[]; 91 win_h=45; 92 win_w=30; 93 windSize = [30,40]; 94 step=1; 95 ps_val_more_than0_3=0.07; 96 count=0; 97 98 disp('正在檢測...'); 99 test_image=imread(test_path); 100 %滑窗檢測,窗口尺度,步長 101 [test_r,test_c,test_z]=size(test_image); 102 figure; 103 imshow(test_image); 104 hold on 105 106 for j_test=1:step:(test_c-win_w+1) 107 for i_test=1:step:(test_r-win_h+1) 108 %model 109 110 model=test_image(i_test:i_test+win_h-1,j_test:j_test+win_w-1,:); 111 %resize 112 test_image_rs=imresize(model,[temp_r1 temp_c1]); 113 test_data=extract_features(test_image_rs,neighbour_pixels_affect,0); 114 test_data=test_data'; 115 test_data=single(test_data); 116 117 [hs,ps] = forestApply( test_data, forest,0,0,1);%尺度問題 118 test_label=[test_label,hs]; 119 test_label_p=[test_label_p,ps(hs)]; 120 %if(ps>ps_val_more_than0_3) 121 if (hs~=11) && (ps(hs)>0.194) 122 %畫框 123 %%%%i_test 124 %j_test 125 count=count+1; 126 %hs 127 switch hs 128 case 1 129 rectangle('Position',[j_test,i_test,30,40],'LineWidth',2,'EdgeColor','r'); 130 case 2 131 rectangle('Position',[j_test,i_test,30,40],'LineWidth',2,'EdgeColor','g'); 132 case 3 133 rectangle('Position',[j_test,i_test,30,40],'LineWidth',2,'EdgeColor','b'); 134 case 4 135 rectangle('Position',[j_test,i_test,30,40],'LineWidth',2,'EdgeColor','c'); 136 case 5 137 rectangle('Position',[j_test,i_test,30,40],'LineWidth',2,'EdgeColor','m'); 138 case 6 139 rectangle('Position',[j_test,i_test,30,40],'LineWidth',2,'EdgeColor','y'); 140 case 7 141 rectangle('Position',[j_test,i_test,30,40],'LineWidth',2,'EdgeColor','b'); 142 case 8 143 rectangle('Position',[j_test,i_test,30,40],'LineWidth',2,'EdgeColor','m'); 144 case 9 145 rectangle('Position',[j_test,i_test,30,40],'LineWidth',2,'EdgeColor','r'); 146 case 10 147 rectangle('Position',[j_test,i_test,30,40],'LineWidth',2,'EdgeColor','g'); 148 end 149 150 %rectangle('Position',[j_test,i_test,30,40],'LineWidth',2,'EdgeColor','r'); 151 %pointAll = [i_test,j_test]; 152 %[state,results]=draw_rect(test_image,pointAll,windSize); 153 hold on 154 end 155 156 end 157 end 158 disp(' the value of count is:') 159 count 160 disp('檢測完畢!恭喜恭喜!') 161 %%%%%%%%%%%%%%%%%%%%%%%%%%

?

轉載于:https://www.cnblogs.com/Wanggcong/p/4940504.html

新人創作打卡挑戰賽發博客就能抽獎!定制產品紅包拿不停!

總結

以上是生活随笔為你收集整理的调试4的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。