Exemple #1
0
def main():

    timeInterval = int(
        ConfigManager.ConfigSectionMap("Basic_Conf")['timeinterval']
    )  ##Assign time interval into variable from config/config.ini file
    threading.Timer(
        timeInterval,
        main).start()  ## called main() function every 'timeInterval' seconds

    cv2.useOptimized()
    blnKNNTrainingSuccessful = DetectChars.loadKNNDataAndTrainKNN(
    )  # attempt KNN training

    if blnKNNTrainingSuccessful == False:  # if KNN training was not successful
        print(
            "\nerror: KNN traning was not successful\n")  # show error message
        return  # and exit program
    # end if

    photo_path = CamManager.get_image()  ##open camera and capture image
    imgOriginalScene = cv2.imread(
        "captured_img/last.png")  # open captured image from directory

    if imgOriginalScene is None:  # if image was not read successfully
        print("\nerror: image not read from file \n\n"
              )  # print error message to std out
        os.system("pause")  # pause so user can see error message
        return  # and exit program
    # end if

    listOfPossiblePlates = DetectPlates.detectPlatesInScene(
        imgOriginalScene)  # detect plates

    listOfPossiblePlates = DetectChars.detectCharsInPlates(
        listOfPossiblePlates)  # detect chars in plates

    if len(listOfPossiblePlates) == 0:  # if no plates were found
        print(
            "\nno plates were detected\n")  # inform user no plates were found
    else:  # else
        # if we get in here list of possible plates has at leat one plate

        # sort the list of possible plates in DESCENDING order (most number of chars to least number of chars)
        listOfPossiblePlates.sort(
            key=lambda possiblePlate: len(possiblePlate.strChars),
            reverse=True)

        # suppose the plate with the most recognized chars (the first plate in sorted by string length descending order) is the actual plate
        licPlate = listOfPossiblePlates[0]

        if len(licPlate.strChars) == 0:  # if no chars were found in the plate
            print("\nno characters were detected\n\n")  # show message
            return  # and exit program
        # end if

        print("\ncharacters read from image = " + licPlate.strChars +
              "\n")  # write license plate text to std out
        print("----------------------------------------")

        mTime = datetime.now().strftime(
            '%Y-%m-%d %H:%M:%S'
        )  ##assign timestamp of measurement to variable 'mTime'
        DBManager.insert_data(
            mTime, int(licPlate.strChars), photo_path
        )  ##insert data into database; timestamp - measured data - photo path

    # end if else

    return
Exemple #2
0
import mysql.connector
from mysql.connector import errorcode
import ConfigManager

########################################
##CONNECTION ARGUMENTS #################
########################################

config = {
	'user'             : ConfigManager.ConfigSectionMap("Basic_Conf")['databaseuser'],
	'password'         : ConfigManager.ConfigSectionMap("Basic_Conf")['databasepass'],
	'host'             : ConfigManager.ConfigSectionMap("Basic_Conf")['host'],
	'database'         : 'EOT_DATA',
	'raise_on_warnings': True,
}

#########################################




##############################
# VARIABLES FROM CONFIG FILE## 
##############################
statcode        = 100; ##Default code; 'Unknown'
cameraNode      = int(ConfigManager.ConfigSectionMap("Basic_Conf")['cameranode']);
unitType        = str(ConfigManager.ConfigSectionMap("Basic_Conf")['unit']);
locationAddress = str(ConfigManager.ConfigSectionMap("Basic_Conf")['location']);
############################

Exemple #3
0
parser.add_argument('-u',  '--unit', help='Set measurement unit [ python settings.py -u <unit> ]', required=False, action='store', type=str) 
##Create new argument '-ti or --timeinterval'
parser.add_argument('-ti', '--timeinterval', help='Set time interval that capture image [ python settings.py -ti <TimeInterval> ]', required=False, action='store', type=int) 
##Create new argument '-stimg or --storeimage'
parser.add_argument('-stimg', '--storeimage', help='Enable/Disable to store captured image [ python settings.py -stimg <true/false> ]', required=False, action='store', type=str) 



##assign arguments to variable 'args' so you can call an argument by 'args.argument'
args = parser.parse_args() 


###################
if args.config:   ##If config argument choosen
   ##Assign DB username from config/config.ini file  into variable 'dbuser'
   dbuser       = ConfigManager.ConfigSectionMap("Basic_Conf")['databaseuser'] 
   ##Assign DB password from config/config.ini file  into variable 'dbpass'
   dbpass       = ConfigManager.ConfigSectionMap("Basic_Conf")['databasepass'] 
   ##Assign DB host from config/config.ini file  into variable 'dbhost'
   dbhost       = ConfigManager.ConfigSectionMap("Basic_Conf")['host']  
   ##Assign Location address from config/config.ini file into variable 'location'   
   location     = ConfigManager.ConfigSectionMap("Basic_Conf")['location'] 
   ##Assign Camera node type from config/config.ini file into variable 'camNode'
   camNode      = ConfigManager.ConfigSectionMap("Basic_Conf")['cameranode'] 
   ##Assign Unit type from config/config.ini file into variable 'unit'
   unit         = ConfigManager.ConfigSectionMap("Basic_Conf")['unit']     
   ##Assign Time Interval from config/config.ini file into variable 'timeInterval'
   timeInterval = ConfigManager.ConfigSectionMap("Basic_Conf")['timeinterval'] 
   ##Assign storeimg value from config/config.ini file into variable 'storeimg'
   storeimg     = ConfigManager.ConfigSectionMap("Basic_Conf")['storeimg']