NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

from picamera.array import PiRGBArray
from picamera import PiCamera
import cv2
import numpy as np
import gpiozero

camera = PiCamera()
image_width = 640
image_height = 480
camera.resolution = (image_width, image_height)
camera.framerate = 32
rawCapture = PiRGBArray(camera, size=(image_width, image_height))
center_image_x = image_width / 2
center_image_y = image_height / 2
minimum_area = 250
maximum_area = 100000

robot = gpiozero.Robot(left=(17,18), right=(27,22))
forward_speed = 0.3
turn_speed = 0.25

HUE_VAL = 28

lower_color = np.array([HUE_VAL-10,100,100])
upper_color = np.array([HUE_VAL+10, 255, 255])

for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
image = frame.array

hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)

color_mask = cv2.inRange(hsv, lower_color, upper_color)

image2, countours, hierarchy = cv2.findContours(color_mask, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

object_area = 0
object_x = 0
object_y = 0

for contour in countours:
x, y, width, height = cv2.boundingRect(contour)
found_area = width * height
center_x = x + (width / 2)
center_y = y + (height / 2)
if object_area < found_area:
object_area = found_area
object_x = center_x
object_y = center_y
if object_area > 0:
ball_location = [object_area, object_x, object_y]
else:
ball_location = None

if ball_location:
if (ball_location[0] > minimum_area) and (ball_location[0] < maximum_area):
if ball_location[1] > (center_image_x + (image_width/3)):
robot.right(turn_speed)
print("Turning right")
elif ball_location[1] < (center_image_x - (image_width/3)):
robot.left(turn_speed)
print("Turning left")
else:
robot.forward(forward_speed)
print("Forward")
elif (ball_location[0] < minimum_area):
robot.left(turn_speed)
print("Target isn't large enough, searching")
else:
robot.stop()
print("Target large enough, stopping")
else:
robot.left(turn_speed)
print("Target not found, searching")

rawCapture.truncate(0)
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.