前言
' ^5 h9 @' B! t* Z/ _我们使用Openmv中的特征点检测进行数字识别,并通过设置红色阈值实现巡线,最后通过串口通信将数字及红线坐标发送给主控芯片。& P' b+ O+ v- g; l
& g; t" ^& S& p* ?# x5 t一、Openmv实现数字识别- j; Y) w+ W$ [2 N/ Y
对于数字识别,一开始我们使用的是模板匹配,后来发现实现过程较为繁琐,且准确率不如特征点检测,故最终采用特征点检测的方法识别6 l& O# l, r N5 M4 G
* X H8 S* Z8 K& J5 n% U$ ^9 q1.这里简单讲一下我们使用模板匹配的思路: `- n2 a1 V0 f0 N t
我们首先采用方框检测,将数字卡片的外边框找到,再对外边框内的图像进行模板匹配,这样做的准确度确实是要比采用整张图像要好得多,但这种方法也有一个非常大的弊端,由于一些外界的干扰,方框大小很容易小于我们采集的模板大小,导致程序不能正常运行,虽然我们适当增加了roi的宽度和长度,但仍会发生这种错误。后来我们经过测试发现,特征点匹配可以达到我们想要的要求。
0 K1 Z. G. D8 |# m8 ^9 `8 L; h2 O- p9 C8 f0 X, f2 D
附上部分代码:
4 J. k$ ^4 o8 q0 S% w, l2 s( J* f* ?$ k. p& _( ~9 N! }. E
- for r in img.find_rects(threshold = 10000):
7 D" B8 u7 P( o0 m- E0 | - img.draw_rectangle(r.rect(), color = (255, 0, 0))
0 Y0 d2 r1 s# i. i' h' ^ - # in r.corners(): #img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))4 f# y! a# U" h z9 g s
- if r:
4 }6 |4 j; @2 b; }- ?1 i - if r[2]<69 or r[3]<75 or r[2]>300 or r[3]>180:#如果小于模板图像的大小,那么ROI设置为整幅图像
4 c# @( J6 S/ k X5 O - template[0]=0& t4 d, `9 G" J4 }
- template[1]=0( e* j# P5 h. G: y
- template[2]=320#宽度要调5 D& e ?3 v4 [+ I
- template[3]=240#高度要调
) X, Q' L1 v/ r) \/ Y - else:# I6 B# U0 Z+ j5 E
- template[0]=r[0]
4 z( o$ P' d/ ]3 Q9 H! S - template[1]=r[1]+ H6 X1 k9 [5 y+ F
- template[2]=r[2]+5#宽度要调2 f0 z& [1 j% P/ A% i2 ~
- template[3]=r[3]+5#高度要调
1 F5 T. B9 z8 F, i. P - print(template)# ~0 j0 u z) S% M f7 a! m
- #近端
" @; c& r8 @6 T ^% ]/ L1 ?1 Z - for n in templates1:
# |+ f! F: {, g2 I - template1 = image.Image(n)1 _ d3 l2 j+ U/ L. t/ w9 t
- #对每个模板遍历进行模板匹配
% M* ?) X% F) G8 v3 Z1 d2 i - r1 = img.find_template(template1, 0.70, step=4, search=SEARCH_EX,roi=(template[0], template[1], template[2], template[3])) #, roi=(10, 0, 60, 60))
, F2 U& J# X' V3 I* D+ a9 I - #find_template(template, threshold, [roi, step, search]),threshold中3 A* x7 c6 [. w$ ]# a9 a: K8 |1 G
- #的0.7是相似度阈值,roi是进行匹配的区域(左上顶点为(10,0),长80宽60的矩形),% y- W$ }- @; }+ C: h- l
- #注意roi的大小要比模板图片大,比frambuffer小。
7 A; T. p" Q" F - #把匹配到的图像标记出来- X7 P' g( c3 Z) G( j
- if r1:' d( A+ E* ^- G0 q$ Y1 z
- #img.draw_rectangle(r1)
' I; n L6 q/ o8 l+ ~& D' n0 X - d="1"6 L, W# W2 O6 v3 }7 K' J5 y
- x=r1[0]
; F% G% E3 i; U- G; O7 A - y=r1[1]& g4 [# E& u; s; U, y- O6 C
- % e/ H# V# _* f8 Q' H& R
- else:
; F- s+ f* P& W: w0 [5 M7 o - d="NO NUM"
: W9 C- k9 L% U3 o, a6 p- L - * y% _! _' ~2 e
- img.draw_string(x,y, d, scale = 2, mono_space = False,
9 l ^( E; `) E; U4 o W" b! Z0 r - char_rotation = 0, char_hmirror = False, char_vflip = False,
& F! M3 b& v T - string_rotat
复制代码
8 Y& N3 K6 k5 Q& h( }" N1 v. O5 S2.我们利用特征点检测的思路:
& O$ d; ~/ q3 _ j* u( m 对于特征点检测,我们通过检测图像特征点,并与我们保存在SD卡的模板进行比对,找到满足特征点数最多的那个模板,即为我们要找的数字,然后我们通过比对一定次数,选出比对成功次数最多的那个数字,作为我们最终的识别结果。在小车对于任务的实现中,我们给出以下思路:
- x/ z9 y2 R, C- Q9 Y# A( g$ u9 J5 n1 @! x: o g" ^$ [9 B
因为近端病房只采用数字1和2,所以我们便想到了一个策略:当识别到为近端病房时,只对数字1和2的特征点进行比对,当远端病房时,对其余数字进行特征点比对,这样很大程度上增加了我们识别的准确性。) V+ n# W; |2 b, y
: \0 E+ R$ g% R$ J' ?
部分代码如下:
( C' r' x, \3 ~4 P4 t2 [- c/ q5 M" E7 N$ Y: ?5 b7 g) e0 \
- if describe_Times<15:5 v/ [) M! d/ `' X4 r
- kpts_run = img.find_keypoints(max_keypoints=220, threshold=1, normalized=False)* u+ Y! ?/ _- l+ s
- match1 = image.match_descriptor(kpts1, kpts_run, threshold=85)
+ v+ N( r) \3 j5 d+ D - match2 = image.match_descriptor(kpts2, kpts_run, threshold=85)% @* v3 f! \: S! U( c# n* m5 h
- 8 X" P- |. A8 e) a g9 y6 H
- match3 = image.match_descriptor(kpts3, kpts_run, threshold=85)$ x6 g8 m- K w
- match4 = image.match_descriptor(kpts4, kpts_run, threshold=85)
, T1 X3 P5 t0 b5 z/ g( X2 A
* X. p: [; g- c0 p! N6 P- match5 = image.match_descriptor(kpts5, kpts_run, threshold=85)
, b: z! v% p0 q3 U0 Y - match6 = image.match_descriptor(kpts6, kpts_run, threshold=85)
' g8 n, ^1 L. x, s$ a8 s
! }1 x" x/ T1 x- match7 = image.match_descriptor(kpts7, kpts_run, threshold=85)
4 f5 {% i5 H& t. Z1 W - match8 = image.match_descriptor(kpts8, kpts_run, threshold=85)
% N) p. e K; V# | - ! e7 S' G) I2 \4 S
- match1_count = match1.count()7 M4 [* \; P( t9 k2 _# X1 O
- match2_count = match2.count()' `& w% X/ `/ G2 E* X( F
- 1 L: q, ^- [! [. u0 f
- match3_count = match3.count()- m! a5 B/ t b* C: V8 B
- match4_count = match4.count()/ h, {# i8 X0 D; Z
- 6 ^& \4 I2 x& ^% e- S3 Q) b
- match5_count = match5.count()7 e/ Q$ ?4 l1 d3 z% K4 y7 C
- match6_count = match6.count()% B- F2 ~0 n7 w
+ p% g- q# Z" m% o, m7 |5 K n- match7_count = match7.count()9 [: E2 N" a f, X# u. G
- match8_count = match8.count()- }6 x2 s/ q& g( k B6 z% q
# [/ `: }" p. F0 L- match_count = max(match3.count(),match4.count(),match5.count(),match6.count(),match7.count(),match8.count())#,match3_2.count(),match4_2.count(),match5_2.count(),match6_2.count(),match7_2.count(),match8_2.count())2 p. w6 s) m& h4 a4 k. `+ q
2 P& i) c8 i1 F3 Z& X+ K3 J$ Q- if (match1_count == match_count):7 b% \) m9 N: j6 u7 d" g, j
- match1_times=match1_times+17 @( P) }; v+ j1 U0 @1 g# t# A
- x[0] = match1.cx()
* h, U. P' ?: c+ K" z - #sending_data(1,x)& n, u$ W5 L: J! \* K% g7 Y
- #print(x1, end = ',')
& A8 a# V | B - print(1,"matched:%d "%(match1.count()))4 I" h! W, j' ?1 o! c2 r$ n
, u: l% T4 Y# R: ?- if (match2_count == match_count):) [$ K( v {. O$ {* n
- match2_times=match2_times+1
7 v5 s* p0 s: Z: U* _ - x[1] = match2.cx()
9 n2 ^: @0 @( ^3 L- @ - #sending_data(2,x)
! V) p' Y* a- H! ? U3 r" u$ M - #print(x2, end = ',') `; [- o2 D% p
- print(2,"matched:%d "%(match2.count()))2 X0 S- ~4 y. R
! e" H7 S, N, H0 H/ W- if (match3_count == match_count):' r# ]3 _* T- e
- match3_times=match3_times+11 m; N! U8 A+ D. ^' c5 M6 F
- t_list[2]=match3_times
" l# H4 J! a. X7 P; ] - x[2] = match3.cx()
% l- s8 ?7 M* F4 ^$ |' K1 `+ T - #x3 = match3.cx()
5 r; W0 u L- d9 @ ]0 b' _, b* m - #sending_data(3,x)
) ^+ l! S( M) E: o. t `2 w - #print(x3, end = ',')1 O& e& n+ Y, {, [' N3 ~3 D
- print(3,"matched:%d "%(match2.count()))+ V9 |' {7 E" Z( o, N+ v+ t4 M& n
- $ A' ~# i+ a. x L2 H
- if (match4_count == match_count):
3 ?. C/ t1 z8 w# ~/ j0 v - match4_times=match4_times+1, x4 v0 y6 r. X- K- ^/ p
- t_list[3]=match4_times+ V; ]4 |/ q: u# f) v# E
- x[3] = match4.cx()- X3 g6 v, f: S! A, r
- #x4 = match4.cx()$ }; J: q6 v' K' |$ C
- #sending_data(4,x)9 u4 X3 K& ]9 r1 S* o
- #print(x4, end = ',')
" G& ]' Y4 k7 `% } - print(4,"matched:%d "%(match4.count()))
: I: m' X7 h6 L
2 m3 t3 x' ?. L/ J- if (match5_count == match_count):
7 k+ B0 ^6 u9 c+ p3 _ - match5_times=match5_times+15 l- c8 ~8 H7 p5 |& w+ E) S3 @
- t_list[4]=match5_times
7 O2 W8 U. \+ h; w5 |3 W( c) C3 ^ - x[4] = match5.cx()
+ Z6 i+ a# X9 s- _6 r% z6 t7 X7 W - #x5 = match5.cx()2 \& f# L, F; O
- #sending_data(5,x)
4 [! g( M0 t5 v, V8 Y4 b/ L - #print(x5, end = ',')% _" ~- `: Q/ Y0 ]! E$ X1 K
- print(5,"matched:%d "%(match5.count()))" i' o" M, G# T9 p) W! R4 v! b7 [
1 i4 i2 u& U; i- if (match6_count == match_count):6 ~/ h8 t- _/ {) {! @. y9 r
- match6_times=match6_times+1
$ q8 R2 ?7 o, e! I - t_list[5]=match6_times# ? d( I6 b+ F5 C9 V
- x[5] = match6.cx()
5 ]; X8 D9 R! i$ L, V - #x6 = match6.cx(). F. r. u- V9 G ?. k2 e9 l
- #sending_data(6,x)
+ ^+ q( h$ d/ H, i2 ?) C - #print(x6, end = ',')
9 V9 S' f0 p3 A4 e3 ~2 a - print(6,"matched:%d "%(match6.count()))/ d. \( P0 T7 T/ W
- ' _' J9 F! R0 ?& `4 B
- if (match7_count == match_count):; b4 X! H; Y' W0 r8 I, u
- match7_times=match7_times+1
y6 v/ P' U" j. P - t_list[6]=match7_times2 G* @4 X3 p9 x: m2 F9 C1 V2 a
- x[6] = match7.cx()
/ D" P1 s, i. H6 v4 ]4 c7 v$ D7 P - #x7 = match7.cx()
1 O' E$ ]/ a; Y# n' o8 M1 M - #sending_data(7,x)1 t. q# \, Y; j' @$ z' a t
- #print(x7, end = ',')3 f2 A1 k: b9 ]& O9 M% P. O7 g
- print(7,"matched:%d "%(match7.count()))4 l; b) _$ B8 l6 ]! U/ d
5 Y/ g3 D6 }' I' a* t2 C; C7 M$ F! w- if (match8_count == match_count):! g# k0 G. o* b! ^8 K
- match8_times=match8_times+16 k2 Q3 |8 b3 P' Y
- t_list[7]=match3_times
" h. k5 ?, S$ O, e - x[7] = match8.cx()
( R/ w" y k/ D# }9 g4 c5 y- } - #x8 = match8.cx()
/ q% y0 X7 J& Y0 ~ - #sending_data(8,x)
5 K, U, v& U0 }$ O4 H2 p - print(8,"matched:%d "%(match8.count()))$ Y( n5 ?/ a' s" {8 @
- 3 L! D3 C% e+ t1 W* F. x
- describe_Times=describe_Times+17 n1 Z& q% q1 A
- else:
- @) _' X7 u/ }: H8 R* y& u - turn_num=t_list.index(max(t_list))+1- Y( a* s$ X' a- i
- sending_data(turn_num,x[turn_num])#数字和坐标
# Z7 \; u1 d( \6 _) t7 `! n: W - print(turn_num,x[turn_num])
+ |& ?) T7 q6 k" \& b! L: b5 t' _ - break;2 e" M8 H; f. m/ Z K
复制代码
/ p5 X2 A) E( J- N/ C4 U二、巡线* a9 V1 G, R" J
1.基本巡线
8 s+ ~6 d, `. {思路:将摄像头一帧图片的上半部分划分为三个平行的感兴趣区,在三个感兴趣区中分别寻找最大的红色色块,获得三个中心坐标,然后给予其不同的权重后计算平均质心坐标,用此质心坐标计算得到巡线时的偏转角度。- V$ I2 O6 l6 ~4 P" z
( R" ?4 s, S9 d' G& R5 b! q
为什么只将一帧图片的上半部分?因为下半部分容易受到小车的阻挡或者阴影干扰
7 w* @$ `! ?/ b) G9 |; v, G& H3 E6 O) h
附上部分代码:# R' x: v: W% K7 d4 A/ T3 H' z
5 o$ i) b: C4 m" Q+ Z+ e8 b
- img = sensor.snapshot()$ F+ J& l+ }8 ^4 ]
- for r in ROIS:#在划分的上半图像中找红线0 J, E0 \4 G1 u5 Y/ z( }; Q1 K
- blobs = img.find_blobs(RED_THRESHOLD, roi=r[0:4], merge=True) # r[0:4]是感兴趣区域的矩形元组.
1 R d* |7 H: Z) s - if blobs:5 J2 G3 t1 z- h) s1 V
- # Find the blob with the most pixels.
. V. W) R0 a4 |2 R+ r' [ - largest_blob = max(blobs, key=lambda b: b.pixels()) # 在blobs中找最大像素值8 V9 V7 I/ }7 n# c; m! T8 F
- img.draw_rectangle(largest_blob.rect())" R) ~3 \' G* _3 J. q
- # 将此区域的像素数最大的颜色块画矩形和十字形标记出来
9 |% V6 |0 _* e/ k; O/ }, x9 E4 \ - img.draw_cross(largest_blob.cx(),largest_blob.cy())+ [( t" d3 n9 b0 q, z& j% B
- Moban_flag=1; q8 l8 l1 V2 e) F
- #print(largest_blob.cx()): }9 h. f( U, Q) n' e7 E- u, N, e
- centroid_sum += (80-largest_blob.cx())*r[4] # 最大值像素点的x坐标*权值 与 图像中心线的偏差值- u4 [; f' D% ~' z6 N0 G& c
- weight_sum = weight_sum + r[4] #权值综合
: m* Z+ ?, F! E! V+ L) J - #计算centroid_sum,centroid_sum等于每个区域的最大颜色块的中心点的x坐标值乘本区域的权值
( ^ N1 Y: w. L8 ]: ^, Y - if weight_sum:
5 k4 l+ u0 G* @. T6 q' c - center_pos = (centroid_sum / weight_sum)
! r/ B. [% M4 k: @$ p5 ]. p) \ - weight_sum = 0
F) I0 V9 s; Y! k4 s0 W - deflection_angle = 0
% S* s. H' R4 n8 N - ns = center_pos/60 # QQVGA 160x120.# M. S( l0 x/ k# [
- deflection_angle = -math.atan(ns)
$ ?% A& u: T0 j1 r7 p, ]% _ - deflection_angle = math.degrees(deflection_angle)' t5 P6 v; n( Q1 S4 b
- deflection_angle = 0 - int(deflection_angle)
) Z8 `5 T( ?' w; d* j) l1 r6 M - #print(str(deflection_angle))8 x, t5 ~' i3 P/ Y4 ?. M5 q
- ##------------------------------------------ 直行 ----------------------------------------------------
" F2 y! \" b9 I0 M$ T% ` - #uart.write(" ")
. z) h$ q4 X1 Y) G- n; o - #uart.write(str(int(deflection_angle)))
: A8 O# ?! d" ?! G3 C, c7 ` - #uart.write(".")
, h' x1 K' ?+ u$ M! A* ~0 f$ v - sending_data(0,deflection_angle)#发送偏移角度
复制代码 . Q- U" M! ^3 O- I8 g7 ?
2.识别十字
: @3 r k" _% e/ c$ b3 u$ ^我们通过判断图像左上方以及右上方区域是否有红线对十字进行识别,若左上角和右上角都有红色部分,那么我们认为小车到达十字路口处。; a( v1 \/ F8 {& R# i0 W
& M( @6 h9 T" P- `) i* h A
部分代码:0 `( l' K7 L. j# N
4 v( x; N& _/ Y, z# @- w- w- ROI = [(10,0,40,50),(110,0,50,50)]#x分别为10和110,Y为0
2 t$ R! ], O J3 P( a - blobs1 = img.find_blobs(RED_THRESHOLD,roi = ROI[0],area_threshold=150,merge=True)#先找左上角红线6 \: ~, O: B9 P4 x* T/ E
- if blobs1:
D* w/ E+ o) ?. y6 |. _: \5 W# A4 v - blobs2 = img.find_blobs(RED_THRESHOLD,roi = ROI[1],area_threshold=150,merge=True)6 {& v1 l( J: e
- if blobs2:: [* j% q, K& ~+ m5 M' L9 }
- print("+")
) Q% t7 A @" I# q* X0 Y - sending_data(10,10)#表示识别到十字
复制代码 4 u1 a4 f! {) \ d: }
三、串口通信( R8 ]) _) v* N
1.数据打包$ t) t7 `9 c3 @( ~# O6 h/ |/ D
有些同学可能会问为什么不直接通过串口发送字符串然后使用sscanf来解析呢呢?
9 N: \. Q2 b9 O7 E& c# m% E9 X2 v$ y( w" [8 G( Q
串口发送字符串(ASCAII编码)的方式比较简单, 用C语言的sscanf()语句解析从语法上是完全可以的, 但是在实际工程上测试,解析不是很稳定,易丢数据。 ASCAII编码易出错,缺乏纠错功能。所以我采用二进制传输的,整数直接发送,浮点数放大去除小数位,然后以C语言的int,short,char的拆分逐8位形式逐位发送。 接收以后先计算校验累加,再重组。这种方式长期使用稳定可靠。5 k8 W I( @" v
这样发出来的数据(int,short型)都是低位的字节在前,比如发送整型数9,得到的数据为(0x09 0x00 0x00 0x00)- a* G3 l* m: [* U; N! @
1 k8 y" ?1 b' }) b附上代码:+ _$ c2 N( P, Z0 f+ a( i
% |% F, O& f) |* N- X- def sending_data(data1,data2):
$ b/ D) [! z9 L- ?8 O' W2 m- I - global uart;$ w. G8 ?/ p7 M! R* p
- #frame=[0x2C,18,cx%0xff,int(cx/0xff),cy%0xff,int(cy/0xff),0x5B];
5 K& t, T6 C4 q- R# Q. k& v - #data = bytearray(frame)
0 P. E+ h/ s" A F0 X6 @ - data = ustruct.pack("<bbii",#<b, #格式为俩个字符俩个短整型(2字节)# n R& k; a: Y3 C
- 0xAA,#帧头1
! W# D% h! ^. o5 M. Z* g - 0xAE, #帧头2+ P6 A, k/ |8 o3 ^' e: n) W) h
- data1,#用于判断
0 W' U8 R) l+ a1 F - data2 #数字
5 c$ E# |6 y& j2 c I. M - )
+ ^( y4 j+ y8 t1 X. d- ~ P, ~ - uart.write(data); #必须要传入一个字节数组
& x3 R9 ^+ _: ^ - #接收9 i- |( {. R: [* k4 \, L0 O, L
- def receive_data():5 W6 }1 Z+ K2 ~; G" ~* ~
- global uart
9 T1 H$ I; I# N6 P0 i) |9 S5 a5 ~+ N - if uart.any():+ ]1 L' g8 B$ p! C% _1 o. Y
- tmp_data = uart.readline();
' x% E+ {% Q8 E0 z6 ]# G5 a* j5 R - return tmp_data;7 d. P( N7 v M* |% l: ^2 q7 Y
- #print(tmp_data)
9 x- |9 ^, [* o" d0 e
复制代码
1 L; ]5 F. C( I+ F2.Openmv及STM32的串口通信
: t ~' [3 Y. S/ X& {% k直接附上STM32解码代码:
4 Z# i$ ?# e7 }/ E9 j
, p# M, ^/ r l- void Optical_Flow_Receive_Prepare(u8 data) `- j( H! y7 Y1 ?9 P
- {" O8 J# { R9 B/ d
- /* 局部静态变量:接收缓存 */0 s3 L$ X. k8 ]( y
- static u8 RxBuffer[10];8 Y- t1 E6 h0 U+ u X
- /* 数据长度 *//* 数据数组下标 */
& A9 ], h5 s- }0 W& [9 E& J - static u8 _data_cnt = 0;
" A( f: Q! n, q* R6 t; H7 b - /* 接收状态 *// N3 `9 l$ A; y" j
- static u8 state = 0;1 K& r$ O$ |6 A, T' g% Y4 M( ]
, D# @( X3 r8 w5 H. L- /* 帧头1 */2 W3 }2 [% B" O+ t
- if(state==0&&data==TITLE1)) J) {% \) C+ n" s
- {
. ?7 U. i. M% |' ~. z5 C% H - state=1;
' _3 u! W1 m, k# J+ B - }
# Q/ Z3 s" D1 n* G+ u9 ` - /* 帧头2 */
/ V' f7 q8 F4 c3 l- {9 }+ I - else if(state==1&&data==TITLE2)
% f8 D4 A' h8 p5 v" H - {
, W7 v. {1 x. \, R - state=2;
3 r" U/ P, M% X( ^. v5 A - _data_cnt = 0;
, ~8 L2 Q r( t - }- h& Q! N6 l- b- A i
- /* 接收数据租 */
1 _: b, C. ^, I+ {. U - else if(state==2)
: X- H; ]9 M9 J" m; v9 { - {2 r! t4 c) r4 `9 x
- RxBuffer[++_data_cnt]=data;
( X$ g& O5 [( D' D: v - if(_data_cnt>=8)* y, |& ]9 d; O# |4 c% t
- {
& Z& ?# N" f1 J2 {! L! F$ B- S - state = 0;+ f$ T# [9 t8 F7 d/ |/ L
- Data_Processing(RxBuffer,_data_cnt);
9 O6 B0 ?/ k6 K* k3 [: ^- q! [6 l# ` - }
# S, x6 {- z& a( ^+ h8 E - }6 A/ h) L4 R( k
- /* 若有错误重新等待接收帧头 */
( [5 ]4 F( K# s+ ]7 q, D' i' H3 f* n - else6 _8 S2 n% u' Y: v5 U' e- K
- state = 0;
! C! a8 |9 U6 z, } - }# w1 S: U" o/ h/ ^5 y
- 0 k' A4 P: ]3 s3 j+ H1 [) G
- . A a. s! S4 N! i
- void Data_Processing(u8 *data_buf,u8 num)
1 ~6 ^% r& q1 g2 \- r0 o7 p0 U' Z - {/ A0 C& \2 [7 @: r& P, t# f
- int theta_org,rho_org;2 n# }4 `$ G$ |
- /* 读取偏移角度原始数据 */
5 B# P( M/ X: {3 f7 z; ] - theta_org = (int)(*(data_buf+1)<<0) | (int)(*(data_buf+2)<<8) | (int)(*(data_buf+3)<<16) | (int)(*(data_buf+4)<<24) ;
6 l3 @7 x1 g: f/ M - theta_err = theta_org;0 f2 y0 S, a; |0 [0 }% p1 S
- 2 h) T3 K% B8 x" P5 M
- /* 读取偏移尺寸原始数据 */
# M5 y. o J* p0 r; U - rho_org = (int)(*(data_buf+5)<<0) | (int)(*(data_buf+6)<<8) | (int)(*(data_buf+7)<<16) | (int)(*(data_buf+8)<<24) ;
* y' J* J/ v6 X4 i6 F7 S1 \5 M# w7 { - rho_err = rho_org;% {# [$ B8 }2 D% i
- }
复制代码
. F) e6 T4 I, m总结: x5 M* K6 S3 R
Openmv功能强大,不仅可以用来做图像的识别处理,其他大家可以去星瞳科技官网去学习,里面有例程的讲解以及丰富的资料$ {$ e* W& m6 E, f+ q8 Q& [
! u0 }# m' i6 h0 x& q2 {) x
3 A* H9 u* D* A7 i |