Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cloud_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

class CloudAnalyzer:
def __init__(self):
self.endPoint = '[CLOUD URL]'
self.apiKey = '[API KEY]'
self.endPoint = 'https://2021csc051-prediction.cognitiveservices.azure.com/customvision/v3.0/Prediction/3afd0fce-ce6c-48dd-b92e-195e9fffc0ef/detect/iterations/Iteration2/image'
self.apiKey = '74a793fe0ad046779ed5d02a3b56def3'

def analyzeImage(self, filePath) -> int:
start_time = time.time()
Expand Down
28 changes: 23 additions & 5 deletions conveyor_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
pygame.init()

# Screen dimensions
SCREEN_WIDTH = 1200
SCREEN_HEIGHT = 1000
SCREEN_WIDTH = 900
SCREEN_HEIGHT = 700

# Port Listening
CONVEYOR_PORT = 12121
Expand All @@ -42,7 +42,7 @@
ARM_WIDTH = 150
BELT_WIDTH = 600
COOKIE_WIDTH = 100
COOKIE_QUALITY = 100 #between 10 and 100
COOKIE_QUALITY = 50 #between 10 and 100
ARM_POSITION = (SCREEN_WIDTH // 2) - ARM_WIDTH // 2
DEV_OFF_Y = SCREEN_HEIGHT // 2 - BELT_WIDTH // 2 - 10
CAM_MARGIN = COOKIE_WIDTH // 4
Expand Down Expand Up @@ -105,7 +105,15 @@ def __init__(self, x, y):
self.shape_arc = BAD_SHAPES[random.randint(1,3)]
else:
self.shape_arc = BAD_SHAPES[0]


# -----------------------------------------------------
self.has_chips = True
self.chip_color = (50, 25, 0) # Dark brown for chocolate chips
self.num_chips = random.randint(3, 7)
self.chip_positions = [(random.randint(10, COOKIE_WIDTH - 10), random.randint(10, COOKIE_WIDTH - 10)) for _ in range(self.num_chips)]
# (added for the choc chips)
# -------------------------------------------------------

def draw(self, screen):
# Draw the full cookie
pygame.draw.ellipse(screen,
Expand All @@ -118,6 +126,15 @@ def draw(self, screen):
[self.x, self.y, COOKIE_WIDTH, COOKIE_WIDTH],
self.shape_arc[0], self.shape_arc[1], self.shape_arc[2])

# ---------------------------------------------------------
if self.has_chips:
for pos in self.chip_positions:
chip_x = self.x + pos[0]
chip_y = self.y + pos[1]
pygame.draw.circle(screen, self.chip_color, (chip_x, chip_y), 7) # radius of the chocolate chip is 7
# (draw choc chips)
# ------------------------------------------------------------

def move(self, speed):
if(self.dead == False) :
self.x += speed
Expand Down Expand Up @@ -217,7 +234,8 @@ def capture(self, screen, capture_area, analyze):

#pygame.transform.smoothscale(capture_image,)
# Save the captured image
imgFile = f"captures/image{self.imgCounter:02}.png"
# imgFile = f"captures/image{self.imgCounter:02}.png"
imgFile = "e:/CSC/cookies/PySimulator/captures/image{:02}.png".format(self.imgCounter)
pygame.image.save(capture_image, imgFile)

#only send image for analysis if opted
Expand Down
4 changes: 2 additions & 2 deletions edge_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

class EdgeAnalyzer:
def __init__(self):
self.endPoint = '[CLOUD URL]'
self.apiKey = '[API KEY]'
self.endPoint = 'http://172.19.100.178:80/image'
self.apiKey = '74a793fe0ad046779ed5d02a3b56def3'

def analyzeImage(self, filePath) -> int:
start_time = time.time()
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ def main():
# 1. isCloud
# =True : Uses cloud module
# =False: Uses edge module
analytic = analytic_module.Listener(isCloud=True)
analytic = analytic_module.Listener(isCloud=False)

# Parameters:
# 1. shouldAnalyzeImg
# =True : To analyze the images
# =False: To get images for training
# 2. imgLimit
# =Number: Number of images/rows to be stored (use 50 to get images for training)
conveyor = conveyor_module.Simulation(shouldAnalyzeImg=False, imgLimit=50)
conveyor = conveyor_module.Simulation(shouldAnalyzeImg=True, imgLimit=50)

analytic.start()
conveyor.start()
Expand Down