提取儀錶盤指標位置

2021-08-20 03:49:16 字數 1824 閱讀 1551

img= imread('2.jpg');%讀取影象

imagebeffor=rgb2gray(img);%轉為灰度影象

figure;

imshow(image); title('濾波後的影象');%顯示影象

level=graythresh(image);%計算全域性閾值

imageth=im2bw(image,level);%二值化

figure;

imshow(imageth); title('圓檢測影象--二值化');%顯示影象

axis on

xlabel x

ylabel y%畫座標

rmin = 50;%搜尋的圓最小半徑

rmax = 300;%搜尋的圓最大半徑

[centersbright, radiibright] = imfindcircles(imageth,[rmin rmax],'objectpolarity','bright','sensitivity',0.95);

viscircles(centersbright, radiibright,'edgecolor','b');%畫出圓

viscircles(centersbright, 0.5*radiibright,'edgecolor','b');%畫出搜尋指標路徑

viscircles(centersbright, 1,'edgecolor','b');%畫圓心

locationx=0;

locationy=0;

count=0;

angle=0;

for j=0:0.05:2*pi

x=centersbright(2)+0.5*radiibright*cos(j);

y=centersbright(1)+0.5*radiibright*sin(j);

x=int32(x);

y=int32(y);

if imageth(x,y)==1%如果遇到白色區域,即為指標位置

viscircles([y,x], 1,'edgecolor','g');

locationx=locationx+x;

locationy=locationy+y;

count=count+1;

angle=angle+j;

endif j==0

viscircles([y,x], 1,'edgecolor','g');

endendlocationx=locationx/count;

locationy=locationy/count;

angle=angle/count;

viscircles([locationy,locationx], 1,'edgecolor','r');%畫出指標位置

figure;

imshow(img); title('原影象');%顯示原影象

figure;

imshow(image); title('灰度影象');%顯示灰度影象

figure;

imshow(imageth); title('二值化影象');%顯示二值化影象

value=(360/(1.5*pi))*(7.0/4.0*pi-angle)%讀取的儀錶盤資料

策略儀錶盤

策略儀錶盤 我們現在已經了解了八大核心驅動力 具體的遊戲技巧和玩家之旅。但是我們要明確的是,遊戲化的目的不是為了樂趣,而是為了提高實際的指標。為了設計成功的遊戲化專案,我們 引入乙個工具 策略儀錶盤。策略儀錶盤包括五個核心部分 商業指標,對應遊戲目的 使用者,對應玩家 期望行為,對應勝利狀態 反饋機...

Android儀錶盤開發

首先 上效果圖 原理就是用canvas畫圓弧.public void drawarc rectf oval,float startangle,float sweepangle,boolean usecenter,paint paint 這裡我們要做的就是先畫乙個黑色的大圓弧,然後再在裡面畫乙個紅色的...

Qt 繪製儀錶盤

1.首先準備素材,乙個表盤,乙個指標 2.計算旋轉圓心及轉動角度 通過畫圖軟體測量一下表盤中心的座標,及指標中心的座標 大概表盤的中心為 163,163 同樣指標的中心位置為 14,110 轉動角度可以大概測量一下,應該為 120,120 度 3.轉動操作 有了這些資料就可以來繪製表盤了 設定表盤的...