Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0b26d0e
added broken roi_bbox and correct roi_bbox_2
Sep 16, 2020
1fd90d3
Merge branch 'master' of https://github.com/albenoit/BachelorDIM-Lect…
Sep 16, 2020
82076ff
added alea + random_fill_parse
Sep 16, 2020
2a977d8
added security
Sep 16, 2020
8f616aa
added travis conf
Sep 16, 2020
51e9233
added pytest tests
Sep 16, 2020
bed3242
added coveralls config
Sep 16, 2020
7ece902
added more tests
Sep 16, 2020
dfdf634
added missing files from previous work
bmx22c Oct 13, 2020
77154a0
Delete keys.py
bmx22c Oct 13, 2020
789f1ee
added missing .gitignore
bmx22c Oct 13, 2020
e4991ca
added missing .gitignore
bmx22c Oct 13, 2020
ee92dea
Delete keys.py
bmx22c Oct 13, 2020
0c96c4f
splitted files and added arguments + counter
bmx22c Oct 13, 2020
dfbb547
Delete keys.py
bmx22c Oct 13, 2020
70de9c5
removed keys
bmx22c Oct 13, 2020
803f1c8
Merge branch 'master' of https://github.com/bmx22c/BachelorDIM-Lectur…
bmx22c Oct 13, 2020
d07c103
added slowdown + concurrency
bmx22c Oct 20, 2020
6394f13
added posts fanout subscriber
bmx22c Oct 20, 2020
e7d3fac
added documentation
bmx22c Oct 30, 2020
61787df
added remove whitespace = optimized random
bmx22c Nov 11, 2020
0efa967
changed wrong var type verification to correct one
bmx22c Nov 11, 2020
f57967c
added Dice Game local player
bmx22c Nov 13, 2020
b70798a
added computer + style
bmx22c Nov 13, 2020
2c290b1
added Doxygen comments
bmx22c Nov 13, 2020
edd9bb7
added more Doxygen comments + code cleaning
bmx22c Nov 13, 2020
e0d8bc0
added selective and bubble sorting method +Doxygen
bmx22c Nov 13, 2020
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
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
service_name: travis-pro
repo_token: uILXAOhaLmKn9ivwmNrT2UAk6OoBK71lz
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CloudAMQP/keys.py
CloudAMQP/__pycache__/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ install:
- pip install -r requirements.txt
addons:
sonarcloud:
organization: albenoit-github
organization: bmx22c-github
# command to run tests
script:
- pytest -v --cov .
Expand Down
34 changes: 34 additions & 0 deletions CloudAMQP/CloudAMQP.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pika
import os
import keys

url = os.environ.get('CLOUDAMQP_URL', keys.amqpkey)
params = pika.URLParameters(url)
params.socket_timeout = 5

# publish
connection = pika.BlockingConnection(params)
channel = connection.channel()
channel.queue_declare(queue='presentation')

channel.basic_publish(exchange='',
routing_key='presentation',
body='Hello World!')

print(" [X] Send 'Hello World!'")
connection.close()

# reader
connection = pika.BlockingConnection(params)
channel = connection.channel()
channel.queue_declare(queue='presentation')

def callback(ch, method, properties, body):
print(" [X] Received %r" % body)

channel.basic_consume(queue='presentation',
on_message_callback=callback,
auto_ack=True)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
Binary file added CloudAMQP/__pycache__/keys.cpython-38.pyc
Binary file not shown.
40 changes: 40 additions & 0 deletions CloudAMQP/publish_fanout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pika
import os
import keys
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--concurrency", "-C", action="store_true")
args = parser.parse_args()

print(args.concurrency)

def sendMessage(message = "Hello World"):
'''
Send message using MQTT

Parameters:
message: the message you want to send (default = "Hello World")
'''
url = os.environ.get('CLOUDAMQP_URL', keys.amqpkey)
params = pika.URLParameters(url)
params.socket_timeout = 5

message = "Hello World!"

# publish
connection = pika.BlockingConnection(params)
channel = connection.channel()
channel.queue_declare(queue='presentation')
channel.exchange_declare(exchange='posts', exchange_type='fanout')

# channel.basic_publish(exchange='',
# routing_key='presentation',
# body=message)

for i in range(0, 100):
channel.basic_publish(exchange='posts', routing_key='', body=message+str(i))

connection.close()

sendMessage()
16 changes: 16 additions & 0 deletions CloudAMQP/queue_publish_read.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--message", "-m", help="Le message a envoyer")
parser.add_argument("-read", action="store_true")
args = parser.parse_args()

print(args.message)
print(args.read)

if args.read:
import simple_queue_read
else:
message = args.message
import simple_queue_publish as pub
pub.sendMessage(message)
45 changes: 45 additions & 0 deletions CloudAMQP/read_subscriber.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import pika
import os
import keys
import argparse
import time

parser = argparse.ArgumentParser()
parser.add_argument("--concurrency", "-C", action="store_true")
args = parser.parse_args()

print(args.concurrency)

url = os.environ.get('CLOUDAMQP_URL', keys.amqpkey)
params = pika.URLParameters(url)
params.socket_timeout = 5

count = 0

# reader
connection = pika.BlockingConnection(params)
channel = connection.channel()
channel.queue_declare(queue='presentation')
channel.exchange_declare(exchange='posts', exchange_type='fanout')

result = channel.queue_declare(queue='', exclusive=True)
queue_name = result.method.queue

channel.queue_bind(exchange='posts', queue=queue_name)

def callback(ch, method, properties, body):
global count
count = count + 1
if args.concurrency:
ch.queue_declare(queue='task_queue', durable=True)
ch.basic_ack(delivery_tag=method.delivery_tag)

ch.basic_qos(prefetch_count=1)
print(" [X] Received %r" % body)
print("J'ai recu " + str(count) + " message(s)")
time.sleep(0.5)

channel.basic_consume(queue=queue_name, on_message_callback=callback, auto_ack=False)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
52 changes: 52 additions & 0 deletions CloudAMQP/simple_queue_publish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import pika
import os
import keys
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--concurrency", "-C", action="store_true")
args = parser.parse_args()

print(args.concurrency)

def sendMessage(message = "Hello World"):
'''
Send message using MQTT

Parameters:
message: the message you want to send (default = "Hello World")
'''
url = os.environ.get('CLOUDAMQP_URL', keys.amqpkey)
params = pika.URLParameters(url)
params.socket_timeout = 5

message = "Hello World!"

# publish
connection = pika.BlockingConnection(params)
channel = connection.channel()
channel.queue_declare(queue='presentation')

# channel.basic_publish(exchange='',
# routing_key='presentation',
# body=message)

for i in range(0, 100):
if args.concurrency:
channel.basic_publish(exchange='',
routing_key='presentation',
body=message+str(i),
properties=pika.BasicProperties(
delivery_mode=2
))
print(" [X] Send '"+message+str(i)+"'")
else:
channel.basic_publish(exchange='',
routing_key='presentation',
body=message+str(i))
print(" [X] Send '"+message+str(i)+"'")


connection.close()

sendMessage()
41 changes: 41 additions & 0 deletions CloudAMQP/simple_queue_read.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import pika
import os
import keys
import argparse
import time

parser = argparse.ArgumentParser()
parser.add_argument("--concurrency", "-C", action="store_true")
args = parser.parse_args()

print(args.concurrency)

url = os.environ.get('CLOUDAMQP_URL', keys.amqpkey)
params = pika.URLParameters(url)
params.socket_timeout = 5

count = 0

# reader
connection = pika.BlockingConnection(params)
channel = connection.channel()
channel.queue_declare(queue='presentation')

def callback(ch, method, properties, body):
global count
count = count + 1
if args.concurrency:
ch.queue_declare(queue='task_queue', durable=True)
ch.basic_ack(delivery_tag=method.delivery_tag)

ch.basic_qos(prefetch_count=1)
print(" [X] Received %r" % body)
print("J'ai recu " + str(count) + " message(s)")
time.sleep(0.5)

channel.basic_consume(queue='presentation',
on_message_callback=callback,
auto_ack=False)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
41 changes: 41 additions & 0 deletions CloudAMQP/simple_queue_read_slower.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import pika
import os
import keys
import argparse
import time

parser = argparse.ArgumentParser()
parser.add_argument("--concurrency", "-C", action="store_true")
args = parser.parse_args()

print(args.concurrency)

url = os.environ.get('CLOUDAMQP_URL', keys.amqpkey)
params = pika.URLParameters(url)
params.socket_timeout = 5

count = 0

# reader
connection = pika.BlockingConnection(params)
channel = connection.channel()
channel.queue_declare(queue='presentation')

def callback(ch, method, properties, body):
global count
count = count + 1
if args.concurrency:
ch.queue_declare(queue='task_queue', durable=True)
ch.basic_ack(delivery_tag = method.delivery_tag)

ch.basic_qos(prefetch_count=1)
print(" [X] Received %r" % body)
print("J'ai recu " + str(count) + " message(s)")
time.sleep(2)

channel.basic_consume(queue='presentation',
on_message_callback=callback,
auto_ack=False)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
76 changes: 76 additions & 0 deletions S3_imgproc_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import cv2
import numpy as np
stream = cv2.VideoCapture(0)

img_gray = cv2.imread('image.jpg', 0)
img_bgr = cv2.imread('image.jpg', 1)

print("Gray levels image", str(img_gray.shape))
print("BGR image", str(img_bgr.shape))

# cv2.imshow("Gray levels image", img_gray)
# cv2.imshow("BGR image", img_bgr)
# cv2.waitKey()

# jusqu'a 128 = invert

def invert_color_manual(input_img):
'''
Invert colors of a given image

Parameters:
input_img: the image you want to invert colors

Returns: the inverted colors image
'''
if input_img is None:
raise ValueError('expected an uint8 nd array')
# if isinstance(input_img, np.ndarray()):
# raise TypeError('expected np array')
if input_img.dtype != np.dtype(np.uint8):
raise TypeError('expected uint8 typed nd array')

inverted_img = np.zeros(input_img.shape, dtype=np.uint8)

inverted_img = 255 - input_img

# for row in range(input_img.shape[0]):
# for col in range(input_img.shape[1]):
# for channel in range(input_img.shape[2]):
# inverted_img[row, col, channel] = 255 - input_img[row, col, channel]

return 255 - input_img

def threshold_image_manual(input_img):
'''
Threshold the colors of a given image

Parameters:
input_img: the image you want to threshold colors

Returns: the threshold colors image
'''
threshold_img = np.zeros(input_img.shape, dtype=np.uint8)
threshold_value = 128

threshold_img = input_img > threshold_value

return threshold_img


while True:
ok, okimg = stream.read()
inverted_img = invert_color_manual(okimg)
threshold_img = threshold_image_manual(okimg)
threshold_img_cast = threshold_img.astype(np.uint8)*255
threshold_img_inverted = threshold_image_manual(inverted_img)
threshold_img_inverted_cast = threshold_img_inverted.astype(np.uint8)*255

cv2.imshow("test", inverted_img)
cv2.waitKey(1)

# cv2.imshow("test", threshold_img_cast)
# cv2.waitKey(1)

# cv2.imshow("test", threshold_img_inverted_cast)
# cv2.waitKey(1)
Loading