logo

请问2后面为什么会有那么多符号,分别代表什么。

2018-06-16 23:27
5
_13531193294

请问2后面为什么会有那么多符号,分别代表什么。

I
网红小智智 星瞳科技

什么符号,请详细说明。

5
_13531193294
8e7c7099-9153-4bdf-85ed-43665334b604.png
I
网红小智智 星瞳科技

https://cn.bing.com/search?q=python3+%E5%AD%97%E8%8A%82%E7%A0%81&qs=n&form=QBRE&sp=-1&pq=python3+%E5%AD%97%E8%8A%82%E7%A0%81&sc=0-17&sk=&cvid=F2088108E66D4A5FB484D5802A5E8C50

2018-06-16 23:37
5
_13531193294

@kidswong999 可以消除后面那些吗,只要接受到的那个信息

I
网红小智智 星瞳科技

你发送的就是这个数据,OpenMV只是给你显示出来了

2018-06-16 23:57
5
_13531193294

@kidswong999 import sensor, image, time

from pyb import UART

from pyb import Servo

import json

#设置阈值

red_threshold_01 = ( 31, 54, 53, 78, 16, 64) #近阈值

red_threshold_02 = ( 8, 57, 23, 78, 16, 64) #远阈值

enable=0

uart = UART(3, 115200)

def dj(b):

step=0

x = b #将b[5]赋值给x

c=abs(80-b) #把cx与中心x值的差赋值给c

#下面为简单的识别舵机运动算法,具体根据实际调试修改参数,可以自行优化

if x > 81:

step=step-int(x-80)

if -800 > step:

step=step+int(x-80)

if x < 79:

step=step+int(80-x)

if step > 900:

step=step-int(80-x)

s1.pulse_width(1480-1*step) #舵机旋转角度

d=step

#print('偏转量 :',step)

#若偏离程度较小则小车加速

if c < 1:

if d == 0:

uart.write('fast\r')

print('jia su')

def dj1(b):

step=0

x = b #将b[5]赋值给x

c=abs(80-b) #把cx与中心x值的差赋值给c

#下面为简单的识别舵机运动算法,具体根据实际调试修改参数,可以自行优化

if x > 81:

step=step-int(x-80)

if -800 > step:

step=step+int(x-80)

if x < 79:

step=step+int(80-x)

if step > 900:

step=step-int(80-x)

s1.pulse_width(1480-2*step) #舵机旋转角度

d=step

#print('偏转量 :',step)

#若偏离程度较小则小车加速

if c < 1:

if d == 0:

uart.write('fast\r')

print('jia su')

sensor.reset()

sensor.set_pixformat(sensor.RGB565)

sensor.set_framesize(sensor.QQVGA)

sensor.set_auto_whitebal(False)

sensor.set_auto_gain(False) #关闭自动亮度增益,太暗了可以自行打开

sensor.set_contrast(3) #设置对比度为3

sensor.set_brightness(-3) #设置亮度最低

sensor.set_auto_exposure(False)

sensor.skip_frames(10)

clock = time.clock()

#用于灭灯时关闭图像识别(dj函数),1为开启,0为关闭

date=1 #默认为开启

s1 = Servo(1) #P7 舵机

s1.pulse_width(1200) #舵机初始化到中间位置

#设置感兴趣区域大小

ROI=(0,0,160,120)

while(True):

img = sensor.snapshot()

#通过读入ardiuo发送过来的信息来控制dj函数关闭与开启

if(uart.any()):

date=uart.read()

print('date= ',date)

#当读入信息为0时,表示开始灭灯,此时不仅要关闭dj函数,还要让舵机中位(为后退做准备)

if date==0:

s1.pulse_width(1480)

#当读入信息为2时,表示后退已完成,开始新一轮转圈

if date==2:

s1.pulse_width(1200)

date=1

#设置感兴趣区域

statistics=img.get_statistics(roi=ROI)

#分阈值查找色块,并返回数组

blobs1 = img.find_blobs([red_threshold_01])

blobs2 = img.find_blobs([red_threshold_02])

#色块在近处

if blobs1:

for b1 in blobs1:

img.draw_rectangle(b1.rect(),color=(255,255,0)) #根据色块大小画黄色框

img.draw_cross(b1.cx(), b1.cy(),color=(255,255,0)) #根据色块中心点画黄色十字架

if date==1:

if b1[5]>=15:

dj(b1[5])

#print('b1[5]= ',b1[5])

#print('jin')

else:

dj1(b1[5])

#print('jin')

#色块不在近处但在远处

else:

if blobs2:

for b2 in blobs2:

if b2[2]>1 and b2[3]>1:

img.draw_rectangle(b2.rect(),color=(255,255,255)) #根据色块大小画白色框

img.draw_cross(b2.cx(), b2.cy(),color=(255,255,255)) #根据色块中心点画白色十字架

if date==1:

if b2[5]>=15:

dj(b2[5])

#print('yuan')

#print('b2[5]= ',b2[5])

else:

dj1(b2[5])

#print('b2[5]= ',b2[5])

#print('yuan')

这是openmv代码,在while(Ture)开头有个接受数据的代码

//=======================================================

// 智能小车超声波测距实验

//===============================================================

#include <Servo.h> //添加舵机库

#include <SoftwareSerial.h>

Servo myservo;

SoftwareSerial softSerial(10, 11);

int Echo = A5; // Echo回声脚

int Trig = A4;// Trig 触发脚()

void Motor_Forward();

void Motor_Back();

void Motor_Stop();

int PWM =5; //定义电机PWM引脚

int DIR =4; //定义电机方向引脚

int val = 200; //电机速度

int Distance1 = 0;

int Distance2 = 0;

int Distance3 = 0;

int Distance= 0;

int a=1;

int flag=1;

void setup()

{

softSerial.begin(9600); // 初始化串口

//初始化电机驱动IO为输出方式

//初始化超声波引脚

pinMode(Echo, INPUT); // 定义超声波输入脚

pinMode(Trig, OUTPUT); // 定义超声波输出脚

pinMode(PWM,OUTPUT);

pinMode(DIR,OUTPUT);

myservo.attach(3); //定义转向舵机

myservo.write(90); //舵机中位

delay(2000); //开机延时

}

void Distance_test() // 量出前方距离

{

digitalWrite(Trig, LOW); // 给触发脚低电平2μs

delayMicroseconds(2);

digitalWrite(Trig, HIGH); // 给触发脚高电平10μs,这里至少是10μs

delayMicroseconds(10);//10us

digitalWrite(Trig, LOW); // 持续给触发脚低电

float Fdistance = pulseIn(Echo, HIGH); // 读取高电平时间(单位:微秒)

Fdistance= Fdistance/58; //为什么除以58等于厘米, Y米=(X秒*344)/2

// X秒=( 2*Y米)/344 ==》X秒=0.0058*Y米 ==》厘米=微秒/58

switch (a){

case 1:Distance1 = Fdistance;

case 2:Distance1 = Fdistance;

case 3:Distance1 = Fdistance;

}

if(a==3){a=0;}

else a++;

Distance=Distance1+Distance2+Distance3;

}

void loop()

{

Distance_test();

Distance_test();

Distance_test(); /*取3次距离平均值*/

if(Distance<30)

{

softSerial.write(1);

delay(1000);

softSerial.write(2);

}

}这是arduino代码,超声波测距信息发送时就会发送数字给openmv但是出现这种情况

8e4944d1-1151-417c-854e-4fee63c76e04.png