Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b955230
my first commit
Sep 15, 2020
c0a85c1
Average
Sep 15, 2020
acd7e56
Average_01
Sep 15, 2020
2e7e2b5
Average_02
Sep 15, 2020
8aa2c0f
Average_03
Sep 15, 2020
76bfe2c
max_value_01
Sep 15, 2020
576d471
reverse_table_01
Sep 16, 2020
02516c4
reverse_table_01
Sep 16, 2020
e161cb1
reverse_table_02
Sep 16, 2020
2670f74
reverse_table_03
Sep 16, 2020
74f215f
Bouding box v1
Sep 16, 2020
98bff3d
Bouding box v2
Sep 16, 2020
60083f3
random_fill_sparse_01
Sep 16, 2020
621be59
random_fill_sparse_01 commented
Sep 16, 2020
ff22842
remove_whitespace_01
Sep 16, 2020
08f523f
Debut shuffle pas terminer
Sep 16, 2020
0828907
Merge branch 'master' of https://github.com/albenoit/BachelorDIM-Lect…
Sep 16, 2020
f086f1c
test des test unitaires
Sep 16, 2020
021f7f2
test des test unitaires 2
Sep 16, 2020
baab3dc
test unitaire v3
Sep 16, 2020
b0acf57
test unitaire v4
Sep 16, 2020
5e016ea
test unitaire v5
Sep 16, 2020
36709b7
test unitaire v6
Sep 16, 2020
711b171
test unitaire v7
Sep 16, 2020
7ff9d34
test unitaire v8
Sep 16, 2020
2b6eb7b
test unitaire v9
Sep 16, 2020
f689c08
Affiche une image en couleur et en gris
Enzo-ltz Sep 29, 2020
1d4d663
Remise dans le bon fichier et invert_color fonctionnel non optimise
Enzo-ltz Sep 29, 2020
4c239c7
Inversion de couleur optimisee et commentaires des fonctions
Enzo-ltz Sep 29, 2020
b8c3e97
Changement nom de fctions
Enzo-ltz Sep 29, 2020
edc73db
invert_color_numpy avec gestion d'erreur de type
Enzo-ltz Sep 29, 2020
eaa0637
T.U invert_color_numpy
Enzo-ltz Sep 29, 2020
de03574
Fin du cours, dernière fonction pas fini
Enzo-ltz Sep 29, 2020
dc0b826
Pulling from teacher master
Oct 13, 2020
e2d7e39
Publisher works fine, key is hidden
Oct 13, 2020
f878abf
Reading works, let's continue !
Oct 13, 2020
a31a5fd
Publish and read, is fonctionnal but not optimized yet
Oct 13, 2020
6386795
As to be finished, end of the lesson
Oct 13, 2020
d9ca761
Able to see how many message are received, with the number of each one
Oct 20, 2020
c9c9a70
Message can now be persistent when using arg -concurrency on simple_q…
Oct 20, 2020
4aeb6cf
Was modifying simple_queue_read for adding argument on -concurrency s…
Oct 20, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mykeys.py
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
python:
- "3.6"
- "3.7"
# command to install dependencies
install:
- pip install -r requirements.txt
Expand Down
211 changes: 211 additions & 0 deletions S1_algotools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
# -*- coding: utf-8 -*-
"""
Éditeur de Spyder

Ceci est un script temporaire.
"""
import numpy as np
import cv2
from random import *

def average(tab):

'''

This funtion calculates the average of a list

Args :
tab: The list of number

Returns the mean of the list

Raises:
Value error if no positive value is find
'''

som = 0
n=0
for i in range(len(tab)):
if tab[i] > 0:
som = som + tab[i]
n = n+1
if n>0:
moy = som/n
else:
raise ValueError('no positive value found')
return(moy)

'''
What happens if som initilization is forgotten ?
L'erreur NameError: name 'som' is not defined
Il faut donc la déclarer

What can you expect if all the values are below zero ?
Le calcul ne les prendra pas en compte
'''

def max_value(tab):

'''

This function returns the maximum value of a list

Args :
tab: The list of number

Returns the maximum value of the list given

'''

max=tab[0]
for i in tab:
if i >= max:
max=i
return(max)

def reverse_table(tab):
'''

This function returns the reverse of the input table

Args :
tab: input table

Returns the inverted table

'''
listlen=len(tab)
for i in range (len(tab)//2):
tmp=tab[i]
endid=listlen-i-1
tab[i]=tab[endid]
tab[endid]=tmp
#tab=tab[::-1]
return(tab)


boolean_matrix=np.zeros((12,10),dtype=bool)
for c in range (7,9):
for l in range (4,9):
boolean_matrix[l,c]=1


def roi_bbox(array):
'''
This function returns a numpy array of shape 4x2 filled with the four 2D coordinates

Args:
lx, ly : Gives x and y coordinates of non null values
coordinates: np.array that contains coordinates of the object
Returns a numpy array of shape 4x2 filled with the four 2D coordinates
'''
lx, ly = np.nonzero(array)
if lx is None or ly is None:
raise ValueError("no non null value found")
else:
coordinates=np.array([
[np.min(lx),np.min(ly)],
[np.max(lx),np.max(ly)]
])
return(coordinates)

char_matrix_empty=np.empty([10,10],dtype=str)


def random_fill_sparse(matrice,k):
'''
This function fills randomly an empty str np array of X

Args :
matrice: Empty np array of str type
k : int corresponding to the number of X that will be placed in matrice
'''

xmax=len(matrice)
ymax=len(matrice[1])
for loop in range(k):
x,y=randint(0,xmax-1),randint(0,ymax-1)
matrice[x,y]='X'
return matrice

def remove_whitespace(string):
'''
This function remove whitespaces from a string

Args :
string: input string that you have to treate

Raises :
TypeError : string is str type only
'''

return(string.replace(' ',''))


"""

/!\ This is just a test to try cv2 library

test=cv2.imread('test.jpg',0)
test1=cv2.imread('test.jpg',1)
cv2.imshow("test",test)
cv2.imshow("test1",test1)
cv2.waitKey()

"""

def invert_color_manual(imgpath):

'''
This function invert the color of the input image path. This ain't optimized for python and very long to apply.

Args :
imgpath: input path of the image you want to convert

Returns the negative of the image
'''

get_picture=cv2.imread(imgpath)


out_picture=np.zeros(get_picture.shape, dtype=np.uint8)

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

return out_picture


def invert_color_numpy(img):
'''
This function invert the color of the input image. This is kind of optimized for python.

Args :
img: input image you want to convert

Returns the negative of the image
'''
if img is None:
raise ValueError('expected an uint8 nd array')
if not (isinstance(img,np.ndarray)):
raise TypeError('expected nd array')
if img.dtype!=np.dtype(np.uint8):
raise TypeError('expected uint8 typed nd aray')

return 255-img

def invert_color_opencv(img):
'''
This function invert the color of the input image. This is kind of optimized for python.

Args :
img: input image you want to convert

Returns the negative of the image
'''
return cv2.bitwise_not(img,1)



Binary file added S1_algotools.pyc
Binary file not shown.
15 changes: 15 additions & 0 deletions S1_algotools_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
"""
Éditeur de Spyder

Ceci est un script temporaire.
"""

import cv2
import numpy as np
test=cv2.imread('test.jpg',0)
test1=cv2.imread('test.jpg',1)
cv2.imshow("test",test)
cv2.imshow("test1",test1)
cv2.waitKey()

9 changes: 9 additions & 0 deletions S4_queues_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 13 13:57:29 2020

@author: lentzye
"""

import mykeys

Binary file added __pycache__/S1_algotools.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/S1_algotools.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/mykeys.cpython-37.pyc
Binary file not shown.
Binary file added __pycache__/test_algo.cpython-27-PYTEST.pyc
Binary file not shown.
Binary file added __pycache__/test_algo.cpython-37-PYTEST.pyc
Binary file not shown.
48 changes: 48 additions & 0 deletions queue_publish_read.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 13 14:37:35 2020

@author: lentzye
"""

import pika, os
import mykeys
import argparse

url = os.environ.get('CLOUDAMQP_URL', mykeys.cloudampqlink)
params = pika.URLParameters(url)
connection = pika.BlockingConnection(params)
channel=connection.channel()
channel.queue_declare(queue='hello')

def publish_queue():

channel.basic_publish(exchange='',
routing_key='hello',
body='Hello CloudAMQP!')
print (" [x] Sent 'Hello World'")


def read_queue():
def callback(ch, method, properties, body):
print("["+str(method.delivery_tag) + "]Received " + str(body))

channel.basic_consume('hello',
callback,
auto_ack=True)

print(' [*] Waiting for messages:')
channel.start_consuming()



parser = argparse.ArgumentParser(description='How to')
parser.add_argument('-read', action='store_true')
flags=parser.parse_args()

if(flags.read):
read_queue()
else :
publish_queue()

connection.close
37 changes: 37 additions & 0 deletions simple_queue_publish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 13 14:03:07 2020

@author: lentzye
"""
import mykeys
import pika, os
import argparse

url = os.environ.get('CLOUDAMQP_URL', mykeys.cloudampqlink)
params = pika.URLParameters(url)
connection = pika.BlockingConnection(params)

channel=connection.channel()
channel.queue_declare(queue='Coucou',durable=True)

parser = argparse.ArgumentParser(description='How to')
parser.add_argument('-concurrency', action='store_true')
flags=parser.parse_args()

if(flags.concurrency):
channel.basic_publish(exchange='',
routing_key="Coucou",
body='Persistentation of un message',
properties=pika.BasicProperties(
delivery_mode = 2, # make message persistent
))
print (" [x] Sentahahah 'Hello World'")

else :
channel.basic_publish(exchange='',
routing_key='hello',
body='Hello CloudAMQP!')
print (" [x] Sent 'Hello World'")

connection.close()
34 changes: 34 additions & 0 deletions simple_queue_read.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 13 14:24:16 2020

@author: lentzye
"""
import mykeys
import pika, os
import argparse

url = os.environ.get('CLOUDAMQP_URL', mykeys.cloudampqlink)
params = pika.URLParameters(url)
connection = pika.BlockingConnection(params)
channel = connection.channel() # start a channel
channel.queue_declare(queue='Coucou',durable=True) # Declare a queue
def callback(ch, method, properties, body):
print(" [x] Received " + str(body))

parser = argparse.ArgumentParser(description='How to')
parser.add_argument('-concurrency', action='store_true')
flags=parser.parse_args()

if(flags.concurrency):
channel.basic_consume('Coucou',
callback,
auto_ack=False)
else :
channel.basic_consume('hello',
callback,
auto_ack=True)


channel.start_consuming()
connection.close()
Binary file added test.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading