导航

    • 登录
    • 搜索
    • 版块
    • 产品
    • 教程
    • 论坛
    • 淘宝
    1. 主页
    2. aznd
    A
    • 举报资料
    • 资料
    • 关注
    • 粉丝
    • 屏蔽
    • 帖子
    • 楼层
    • 最佳
    • 群组

    aznd

    @aznd

    0
    声望
    6
    楼层
    517
    资料浏览
    0
    粉丝
    0
    关注
    注册时间 最后登录

    aznd 关注

    aznd 发布的帖子

    • openmv脱机运行能正常发送数据,但是不能接收数据,这是为什么?

      openmv在IDE运行时,串口接收和发送数据都是正常的,但是脱机运行时,能正常发送数据却不能正常接收数据,这是什么原因?

      import sensor, image, time, os, tf, math, uos, gc
      from pyb import UART, Timer, LED
      sensor.reset()
      sensor.set_pixformat(sensor.GRAYSCALE)
      sensor.set_framesize(sensor.QQVGA)
      sensor.set_windowing((240, 240))
      sensor.skip_frames(time=2000)
      net = None
      labels = None
      min_confidence = 0.5
      try:
      	net = tf.load("trained.tflite", load_to_fb=uos.stat('trained.tflite')[6] > (gc.mem_free() - (64*1024)))
      except Exception as e:
      	raise Exception('Failed to load "trained.tflite", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')
      try:
      	labels = [line.rstrip('\n') for line in open("labels.txt")]
      except Exception as e:
      	raise Exception('Failed to load "labels.txt", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')
      colors = [
      	(255,   0,   0),
      	(  0, 255,   0),
      	(255, 255,   0),
      	(  0,   0, 255),
      	(255,   0, 255),
      	(  0, 255, 255),
      	(255, 255, 255),
      ]
      clock = time.clock()
      global uart_r
      uart_r = [0xAA, 0xAF, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00]
      class Saveimage(object):
      	def __init__(self):
      		pass
      	def Recognize(self,img):
      		self.img = img
      		for i, detection_list in enumerate(net.detect(self.img, thresholds=[(math.ceil(min_confidence * 255), 255)])):
      			if (i == 0): continue
      			if (len(detection_list) == 0): continue
      			print("recognize to: "+labels[i])
      			if labels[i]=='lin':
      				sensor.snapshot().save("lin.jpg")
      				uart_bufl[6] = 0xAA
      				print("Save lin.")
      			elif labels[i]=='ke':
      				sensor.snapshot().save("ke.jpg")
      				uart_bufl[6] = 0xBB
      				print("Save ke.")
      			elif labels[i]=='da':
      				 sensor.snapshot().save("da.jpg")
      				 uart_bufl[6] = 0xCC
      				 print("Save da.")
      			sensor.snapshot().save("other.jpg")
      			print("Save other.")
      Saveimg=Saveimage()
      uart = UART(3,115200)
      uart.init(115200,8, parity=None, stop=1)
      def ReceiveB():
      	global uart_r
      	size = uart.any()
      	if size<=len(uart_r):
      		for i in range(0,size):
      			uart_r[i] = uart.readchar()
      	if uart_r[0]!=0xAA:
      		uart_r = [0xAA, 0xAF, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00]
      		LED(1).on()
      		LED(2).off()
      	elif uart_r[1]!=0xAF:
      		uart_r = [0xAA, 0xAF, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00]
      		LED(1).on()
      		LED(2).off()
      	elif uart_r[2]!=0x05:
      		uart_r = [0xAA, 0xAF, 0x05, 0x02, 0x00, 0x00, 0x00, 0x00]
      		LED(1).on()
      		LED(2).off()
      	else:
      		LED(1).off()
      		LED(2).on()
      uart_bufl = bytearray([0xAA,0xFF, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
      def uartsend(timer):
      	uart.write(uart_bufl)
      def updatesend(custom, cx, cy, distance):
      	i=0
      	sum = 0
      	add = 0
      	uart_bufl[2] = custom;
      	uart_bufl[4] = cx;
      	uart_bufl[5] = cy;
      	uart_bufl[6] = distance;
      	uart_bufl[3] = len(uart_bufl)-6;
      	while i<(len(uart_bufl)-2):
      		sum = sum+uart_bufl[i]
      		add = add+sum
      		i+=1
      	uart_bufl[-2] = sum;
      	uart_bufl[-1] = add;
      tim = Timer(2, freq=20)
      tim.callback(uartsend)
      while(True):
      	clock.tick()
      	ReceiveB()
      	print(str(uart_r))
      	if uart_r[5]==0xDD:
      		img0 = sensor.snapshot()
      		Saveimg.Recognize(img0)
      		LED(3).on()
      		LED(1).off()
      		LED(2).off()
      		print("Saving......")
      	elif uart_r[5]==0xEE:
      		if uart_r[4]!=0x06:
      			print("Now is locking mode\r\n")
      			img1 = sensor.snapshot()
      			lockimg = ''
      			for i, detection_list in enumerate(net.detect(img1, thresholds=[(math.ceil(min_confidence * 255), 255)])):
      				if (i == 0): continue
      				if (len(detection_list) == 0): continue
      				lockimg = labels[i]
      				uart_bufl[7] = 0xCC
      				print('reading:'+lockimg)
      		else:
      			img2 = sensor.snapshot()
      			for k, detection_list in enumerate(net.detect(img2, thresholds=[(math.ceil(min_confidence * 255), 255)])):
      				if (k == 0): continue
      				if (len(detection_list) == 0): continue
      				if labels[k]==lockimg:
      					print(lockimg+labels[k]+'\r\n')
      					for d in detection_list:
      						[x, y, w, h] = d.rect()
      						center_x = math.floor(x + (w / 2))
      						center_y = math.floor(y + (h / 2))
      						distance = int((80-center_x)*100*0.0024/0.42)
      						uart_bufl[4] = center_x
      						uart_bufl[5] = center_y
      						uart_bufl[6] = distance
      						LED(3).on()
      						LED(1).off()
      						LED(2).off()
      						print('%d',distance)
      				else:
      					uart_bufl[6] = 0x3C
      					print("Don't get picture!")
      	else:
      		print("Wait enter a recognization mode!")
      	print(clock.fps(), "fps", end="\n\n")
      
      发布在 OpenMV Cam
      A
      aznd
    • openmv IDE一链接到openmv上运行代码就忙碌,这是为什么呢?

      0_1658823966843_25c94138-a7a7-4271-b5d5-8a8620dea12e-image.png

      发布在 OpenMV Cam
      A
      aznd
    • RE: 这个问题是我的缓冲区太小了吗,为什么加载不了神经网络的模型?怎么解决这个问题呢?

      @kidswong999 我是用的FOMO模型啊,而且图片都没够200张
      0_1658055329731_89928edb-dd07-4067-877f-31ee432b39b2-image.png

      发布在 OpenMV Cam
      A
      aznd
    • RE: 这个问题是我的缓冲区太小了吗,为什么加载不了神经网络的模型?怎么解决这个问题呢?

      我是用的FOMO模型啊,而且图片都没够200张

      发布在 OpenMV Cam
      A
      aznd
    • 这个问题是我的缓冲区太小了吗,为什么加载不了神经网络的模型?怎么解决这个问题呢?

      0_1657980966628_1.png

      
      

      请在这里粘贴代码

      Edge Impulse - OpenMV Object Detection Example

      import sensor, image, time, os, tf, math, uos, gc

      sensor.reset() # Reset and initialize the sensor.
      sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
      sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
      sensor.set_windowing((240, 240)) # Set 240x240 window.
      sensor.skip_frames(time=2000) # Let the camera adjust.

      net = None
      labels = None
      min_confidence = 0.5

      try:
      # load the model, alloc the model file on the heap if we have at least 64K free after loading
      net = tf.load("trained.tflite", load_to_fb=uos.stat('trained.tflite')[6] > (gc.mem_free() - (64*1024)))
      except Exception as e:
      raise Exception('Failed to load "trained.tflite", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')

      try:
      labels = [line.rstrip('\n') for line in open("labels.txt")]
      except Exception as e:
      raise Exception('Failed to load "labels.txt", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')

      colors = [ # Add more colors if you are detecting more than 7 types of classes at once.
      (255, 0, 0),
      ( 0, 255, 0),
      (255, 255, 0),
      ( 0, 0, 255),
      (255, 0, 255),
      ( 0, 255, 255),
      (255, 255, 255),
      ]

      clock = time.clock()
      while(True):
      clock.tick()

      img = sensor.snapshot()
      
      # detect() returns all objects found in the image (splitted out per class already)
      # we skip class index 0, as that is the background, and then draw circles of the center
      # of our objects
      
      for i, detection_list in enumerate(net.detect(img, thresholds=[(math.ceil(min_confidence * 255), 255)])):
          if (i == 0): continue # background class
          if (len(detection_list) == 0): continue # no detections for this class?
      
          print("********** %s **********" % labels[i])
          for d in detection_list:
              [x, y, w, h] = d.rect()
              center_x = math.floor(x + (w / 2))
              center_y = math.floor(y + (h / 2))
              print('x %d\ty %d' % (center_x, center_y))
              img.draw_circle((center_x, center_y, 12), color=colors[i], thickness=2)
      
      print(clock.fps(), "fps", end="\n\n")
      
      
      

      请在这里粘贴代码

      发布在 OpenMV Cam
      A
      aznd
    • openmv4 H7 R2 是不是完全做不了神经网络,我的跑不起来,有没有什么解决方法?
      # Edge Impulse - OpenMV Image Classification Example
      
      import sensor, image, time, os, tf, uos, gc
      
      sensor.reset()                         # Reset and initialize the sensor.
      sensor.set_pixformat(sensor.RGB565)    # Set pixel format to RGB565 (or GRAYSCALE)
      sensor.set_framesize(sensor.QVGA)      # Set frame size to QVGA (320x240)
      sensor.set_windowing((240, 240))       # Set 240x240 window.
      sensor.skip_frames(time=2000)          # Let the camera adjust.
      
      net = None
      labels = None
      
      try:
          # load the model, alloc the model file on the heap if we have at least 64K free after loading
          net = tf.load("trained.tflite", load_to_fb=uos.stat('trained.tflite')[6] > (gc.mem_free() - (64*1024)))
      except Exception as e:
          print(e)
          raise Exception('Failed to load "trained.tflite", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')
      
      try:
          labels = [line.rstrip('\n') for line in open("labels.txt")]
      except Exception as e:
          raise Exception('Failed to load "labels.txt", did you copy the .tflite and labels.txt file onto the mass-storage device? (' + str(e) + ')')
      
      clock = time.clock()
      while(True):
          clock.tick()
      
          img = sensor.snapshot()
      
          # default settings just do one detection... change them to search the image...
          for obj in net.classify(img, min_scale=1.0, scale_mul=0.8, x_overlap=0.5, y_overlap=0.5):
              print("**********\nPredictions at [x=%d,y=%d,w=%d,h=%d]" % obj.rect())
              img.draw_rectangle(obj.rect())
              # This combines the labels and confidence values into a list of tuples
              predictions_list = list(zip(labels, obj.output()))
      
              for i in range(len(predictions_list)):
                  print("%s = %f" % (predictions_list[i][0], predictions_list[i][1]))
      
          print(clock.fps(), "fps")
      

      0_1657885045213_baocuo.png

      发布在 OpenMV Cam
      A
      aznd