.gitignore updated, little fixes
This commit is contained in:
		
							
								
								
									
										38
									
								
								IFPass.py
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								IFPass.py
									
									
									
									
									
								
							@@ -2,14 +2,10 @@
 | 
			
		||||
 | 
			
		||||
# Written by Jordan ERNST Q1 2018.
 | 
			
		||||
# Contact : pro.ernst@gmail.com
 | 
			
		||||
# v1.0 : 23/03/2018
 | 
			
		||||
 | 
			
		||||
# https://www.pyimagesearch.com/2015/12/21/increasing-webcam-fps-with-python-and-opencv/
 | 
			
		||||
 | 
			
		||||
import sys
 | 
			
		||||
import os
 | 
			
		||||
import re
 | 
			
		||||
from contextlib import contextmanager    # To hide output
 | 
			
		||||
from datetime import date, timedelta
 | 
			
		||||
import csv
 | 
			
		||||
import code128
 | 
			
		||||
@@ -25,11 +21,11 @@ from colorama import init
 | 
			
		||||
from termcolor import colored
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
version = '1.0'
 | 
			
		||||
version = 'dev'
 | 
			
		||||
 | 
			
		||||
computer = ''      # 'test', 'mediatheque' or 'accueil'
 | 
			
		||||
computer = ''      # 'mediatheque' or 'accueil'
 | 
			
		||||
 | 
			
		||||
if computer == 'test':
 | 
			
		||||
if version == 'dev':
 | 
			
		||||
    IFPassdir = '\\\\192.168.1.1\SSIC\\04-Projets\IFPass\\'
 | 
			
		||||
elif computer == 'mediatheque':
 | 
			
		||||
    IFPassdir = '\\\\192.168.1.1\IFPass\\'
 | 
			
		||||
@@ -42,31 +38,13 @@ else:
 | 
			
		||||
    sys.exit()
 | 
			
		||||
 | 
			
		||||
clientsfile = IFPassdir + 'Clients_IFPass.csv'
 | 
			
		||||
clientsbkpfile = IFPassdir + 'Clients_IFPass_bakup.csv'
 | 
			
		||||
clientsbkpfile = IFPassdir + 'Clients_IFPass_backup.csv'
 | 
			
		||||
imgdir = IFPassdir + 'Cartes\\'
 | 
			
		||||
pdftemplate = IFPassdir + 'Templates\IFPass_PDF_Template.pdf'
 | 
			
		||||
pngtemplate = IFPassdir + 'Templates\IFPass_PNG_Template.png'
 | 
			
		||||
fonttemplate = IFPassdir + 'Templates\Roboto-Bold.ttf'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@contextmanager
 | 
			
		||||
def HideOutput(to=os.devnull):
 | 
			
		||||
    fd = sys.stdout.fileno()
 | 
			
		||||
 | 
			
		||||
    def _redirect_stdout(to):
 | 
			
		||||
        sys.stdout.close()  # + implicit flush()
 | 
			
		||||
        os.dup2(to.fileno(), fd)  # fd writes to 'to' file
 | 
			
		||||
        sys.stdout = os.fdopen(fd, 'w')   # Python writes to fd
 | 
			
		||||
 | 
			
		||||
    with os.fdopen(os.dup(fd), 'w') as old_stdout:
 | 
			
		||||
        with open(to, 'w') as file:
 | 
			
		||||
            _redirect_stdout(to=file)
 | 
			
		||||
        try:
 | 
			
		||||
            yield  # allow code to be run with the redirected stdout
 | 
			
		||||
        finally:
 | 
			
		||||
            _redirect_stdout(to=old_stdout)  # restore stdout.  # cv2.selectROI
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_fullname():
 | 
			
		||||
    firstname = input("Prénom : ").strip()
 | 
			
		||||
    firstname = firstname[0].upper() + firstname[1:].lower()
 | 
			
		||||
@@ -127,12 +105,11 @@ def getpic():
 | 
			
		||||
            try:
 | 
			
		||||
                ret, frame = cap.read()
 | 
			
		||||
                cv2.rectangle(frame, (170, 73), (470, 407), (0, 255, 0), 2)
 | 
			
		||||
                cv2.imshow('IFCamera - Touche Espace pour prendre la photo, Echap pour une carte sans photo, Q pour quitter.',
 | 
			
		||||
                       frame)
 | 
			
		||||
                cv2.imshow('IFCamera - Touche Espace pour prendre la photo, Echap pour une carte sans photo, Q pour quitter.', frame)
 | 
			
		||||
            except cv2.error:
 | 
			
		||||
                print('\nLa webcam est débranchée. Branchez-la, puis relancez le programme.')
 | 
			
		||||
                print(colored('\nLa webcam est débranchée. Branchez-la, puis relancez le programme.', 'red'))
 | 
			
		||||
                os.system("pause")
 | 
			
		||||
                sys.exit(0)
 | 
			
		||||
                sys.exit()
 | 
			
		||||
            SetForegroundWindow(find_window(title='IFCamera - Touche Espace '
 | 
			
		||||
                                            'pour prendre la photo, Echap pour une carte sans photo, Q pour quitter.'))
 | 
			
		||||
            k = cv2.waitKey(1)
 | 
			
		||||
@@ -281,3 +258,4 @@ while "the informations are incorrect":              # Loop Filling informations
 | 
			
		||||
        bkpdb()
 | 
			
		||||
        if computer == 'mediatheque' or computer == 'accueil':
 | 
			
		||||
            printcard(cartefilename)
 | 
			
		||||
        sys.exit()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user