def main():
    files = common.getFiles(pattern = 'dataset/captures/*.tiff')
    file = files[2]
    img = cv2.imread(file)
    background = cv2.imread('dataset/background.tiff')
    success,_ , points = work_frame.findAndDrawContours(background.copy())
    snooker = Snooker()
    if success:    
        dst = work_frame.changePerspective(points,img)
        dst1 = dst.copy()
        back = work_frame.changePerspective(points,background)
        dst_gray = cv2.cvtColor(dst,cv2.COLOR_BGR2GRAY)
        back_gray = cv2.cvtColor(back,cv2.COLOR_BGR2GRAY)
        diff = cv2.subtract(dst,back)
        diff_gray = cv2.subtract(dst_gray,back_gray)
        diff_gray1 = cv2.cvtColor(diff,cv2.COLOR_BGR2GRAY)
        #cv2.imshow('diff_gray',diff_gray)
        #cv2.imshow('diff',diff)
        _ , mask_inv = cv2.threshold(diff_gray,60,255,cv2.THRESH_BINARY)
        kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(3,3))
        dilate = cv2.dilate(mask_inv,kernel,iterations = 2)
        #dilate = mask_inv
        circles_cont = detectBallContour(dst1,dilate)
        circles_hough = detectHough(dst,dilate)
      
        cv2.imshow('dst_hough',dst)
        cv2.imshow('dst_contour',dst1)
        cv2.imshow('dilate',dilate)
        cv2.waitKey(0)
Example #2
0
def format(dir):
    files = common.getFiles(dir, ".h;.cpp;.inl")
    
    for file in files:
        subprocess.call(['clang-format', '-style=file', '-i', file])
        indentPreprocessorDirectives(file)
        print("\t", file)
Example #3
0
def main():
    files = common.getFiles()
    background = cv2.imread(background_address)
    _, _, points = work_frame.findAndDrawContours(background.copy())
    background = work_frame.changePerspective(points, background)
    back_gray = cv2.cvtColor(background, cv2.COLOR_BGR2GRAY)
    for f in files:
        img = cv2.imread(f)
        img = work_frame.changePerspective(points, img)
        mask = work_frame.getDilatedMask(img, back_gray)
        circles = ball_tracker.detectBallContour(img, mask)
        cv2.imshow('img', img)
        cv2.waitKey(0)
        cv2.destroyWindow('img')
Example #4
0
    def loadData(self):
        self.homeFiles = {}

        res = []
        for f in common.getFiles("data", ".jhome"):
            if "_bak" not in f:
                home = appart.Home()
                jsonTools.load(home, f)
                if home.hidden or home.sold:
                    continue
                res.append(home)
                self.homeFiles[home] = f
        self.homes = res
        return res
Example #5
0
def addHeaders(dir, headerFile, start, end):
    with open(headerFile) as f:
        header = f.readlines()

    header.insert(0, start)
    header += ['\n', end, '\n']
    # Get all files
    files = common.getFiles(dir, ".h;.cpp;.inl")
    for file in files:
        with open(file, 'r+') as f:
            data = f.readlines()
            if data.count(end) > 0:
                i = data.index(end)
                del data[0:i + 1]
            
            # Add header
            data = header + data
            f.seek(0)
            f.writelines(data)
            f.truncate()
            print("\t" + file)
Example #6
0
def main():
    startTime = time.time()
    
    # Parse arguments
    parser = argparse.ArgumentParser()
    parser.add_argument("--standardese-path", dest="standardesePath", action="store", help="The path to the standardese binary", required=True)
    parser.add_argument("--quiet", dest="quiet", action="store_true", help="Don't show CMake or standardese output")
    args = parser.parse_args()
    
    # Generate docs using CMake and Standardese
    buildDir = os.path.join(common.getRoot(), "_Temp", "Docs", "Engine")
    common.mkdir(buildDir)
    common.callBlocking(not (args.quiet), ["cmake", 
                                       "-DGENERATE_DOCS=ON", 
                                       "-DGENERATE_TESTS=OFF", 
                                       "-DGENERATE_DEMOS=OFF", 
                                       "-DGENERATE_PLUGINS=OFF", 
                                       "-B" + buildDir, 
                                       "-H" + common.getRoot(), 
                                       "-DSTANDARDESE_TOOL=" + args.standardesePath])
    common.callBlocking(not (args.quiet), ["cmake", 
                                       "--build", buildDir, 
                                       "--target", "standardese_docs_engine"])
    
    # Copy generated docs to Docs
    generatedDir = os.path.join(buildDir, "standardese_docs_engine")
    copyDir = os.path.join(common.getRoot(), "Docs", "Engine")
    common.mkdir(copyDir)
    docFiles = common.getFiles(generatedDir, ".md")
    for file in docFiles:
        # Below functionality is for updating only a single file, but it doesn't quite work well yet because standardese can't link to other files in this mode
        #if os.stat(file).st_mtime > os.stat(os.path.join(copyDir, os.path.basename(file))).st_mtime:
        #    print("\t" + file)
        shutil.copy2(file, copyDir)
    
    print("Done! {} seconds".format(time.time() - startTime))
def main():
	modified = 0
	for filename in common.getFiles(common.fileIsC):
		indent = ''
		singleindent = ''
		corrected = []
		lineAboveIsBlank = False
		file = open(filename, 'r')
		for line in file:
			if '}' in line and isPreceded(line, '}'):
				indent = indent[:-1]
			i = 0
			while i < len(line) and line[i] in WS_CHARS:
				i += 1
			if not (lineAboveIsBlank and lineIsBlank(line)):
				corrected.append(indent + singleindent + line[i:])
			if lineIsBlank(line):
				lineAboveIsBlank = True
			else:
				lineAboveIsBlank = False
			if '{' in line:
				indent += '\t'
			if '}' in line and not isPreceded(line, '}'):
				indent = indent[:-1]
			if isSingleLoop(line) and '{' not in line:
				singleindent += '\t'
			else:
				singleindent = ''
		file.close()
		file = open(filename, 'w')
		file.truncate()
		for line in corrected:
			file.write(line)
		file.close()
		modified += 1
	print("%d files were corrected" % modified)
Example #8
0
def parseHomeDir(dirPath, url=None):
    files = common.getFiles(dirPath, [".htm", ".html"], recursive=False, onlyFiles=True)
    if len(files) >= 1:
        return parseLocal(files[0], url)
def main():
	lines = 0
	for filename in common.getFiles(common.isValidCode):
		lines += lengthOf(filename)
	print("%d lines of code were found" % lines)