Example #1
0
            <script src="displayHandles.js"></script>
        </head>
        <body>"""

        # try multiple simplification
        for s in range(nbSimple):  # nb de simplification
            subprocess.call([
                "cp", outputFolder + "/" + iName + "-simpl" + str(s) + ".svg",
                outputFolder + "/" + iName + "-simpl" + str(s + 1) + ".svg"
            ])
            # print("cp","Glyphes/vectors/"+iName+"-simpl"+str(s)+".svg","Glyphes/vectors/"+iName+"-simpl"+str(s+1)+".svg")
            subprocess.call([
                "inkscape", "--verb=EditSelectAll", "--verb=SelectionSimplify",
                "--verb=FileSave", "--verb=FileQuit",
                outputFolder + "/" + iName + "-simpl" + str(s + 1) + ".svg"
            ])
            # print("inkscape","--verb=EditSelectAll","--verb=SelectionSimplify","--verb=FileSave","--verb=FileQuit","Glyphes/vectors/"+iName+"-simpl"+str(s+1)+".svg")
            # subprocess.call(["inkscape","--verb=EditSelectAll","--verb=SelectionSimplify","--export-plain-svg='Glyphes/vectors/"+iName+"-simpl"+str(s+1)+".svg'","Glyphes/vectors/"+iName+"-simpl"+str(s)+".svg"])
            html += "\n<object class='obj' data='{}' width='200px' height='200px' onload='draw(this)'></object>".format(
                iName + "-simpl" + str(s + 1) + ".svg")

        html += """
        </body>
        </html>
        """
        if ifHTML:
            with open(outputFolder + "/" + iName + ".html", 'wb') as f:
                f.write(html.encode('utf8'))

        Bar.update()
Example #2
0
                        area = extracthocr.zoning(imgPage, n, margin)

                        outputName = glyphStr + "-" + str(int(confidenceValue)) + "-" + str(pageNumber) + "-" + str(word_id) + "-" + str(globalAreaCounter) + ".png"
                        if glyphStr == ".":  # to fix "." name
                            if not os.path.isdir(outputFolderFamily + ".point"):
                                os.mkdir(outputFolderFamily + ".point")
                            area.save(outputFolderFamily + ".point/" + outputName)
                        else:
                            if not os.path.isdir(outputFolderFamily + glyphStr):
                                os.mkdir(outputFolderFamily + glyphStr)
                            area.save(outputFolderFamily + "/" + glyphStr + "/" + outputName)

                        # area.save(outputFolder + outputName)
                        globalAreaCounter += 1
                        BarByPage.update()
                        # coordsCorpList.append(coordCrop)
                if mode == "word":
                    words = firstPage.find_all(attrs={"class": u"ocrx_word"})

                    for word in words:
                        fontFamily = getFontFamily(word, stylised_nodes, fontStyles)
                        if len(specificStyles) > 0 and not fontFamily in specificStyles:
                            continue

                        word_id = word.get('id')

                        wordStr = word.findAll(text=True, recursive=False)

                        if len(wordStr) > 0:
                            wordStr = wordStr[0]