blueaxis / Poricom

Optical character recognition in manga images. Manga OCR desktop application
GNU General Public License v3.0
276 stars 18 forks source link

Does anyone know if there's a way to change where the OCR txt is logged to? #37

Open mellow-tnk opened 1 year ago

mellow-tnk commented 1 year ago

Currently, everything is being saved into log.txt. If I have several hundred images, everything is being logged into one txt file which makes it hard to manage and track. So currently, after every image, I rename the log file to the same filename as the image.

Is there a way for it to automatically save txt into individual txt files that have the same filename as the image by default? Or a better way to manage/track the OCR text being added to log.txt?

blueaxis commented 1 year ago

Text logging works on a per directory basis rather than per image, so the only way do to this is to rename each text file

mellow-tnk commented 1 year ago

in order to make it per each image file instead of directory, would it be a good idea to change default behavior? Instead of saving to "log.txt", change it to filename.txt?

in Poricom/app/components/views/ocr/base.py

def mouseReleaseEvent(self, event):
    logPath = join(self.explorerPath, "text-log.txt")
    text = self.canvasText.text()
    logText(text, isLogFile=self.logToFile, path=logPath)
    try:
        if not self.persistText:
            self.canvasText.hide()
    except AttributeError:
        pass
    super().mouseReleaseEvent(event)

so instead of logPath = join(self.explorerPath, "text-log.txt") it'll be something like logPath = join(self.explorerPath, "text-"+os.path.splitext(file_name)[0]+".txt") or maybe logPath = join(self.explorerPath, "text-", os.path.splitext(file_name)[0], ".txt")

it's been like 10 years since I last coded, so I'm not sure if that'll work. Edit: or not since how would you know what filename it is if you're using external view? or maybe default to log.txt for external. I don't know.

blueaxis commented 1 year ago

The filename of the current image can be accessed using self.states.baseImage.filename. In split view mode, this defaults to the left image. But as you've mentioned, external view captures must be handled as well. Also, I think this must be optional since some users might prefer logging in one file. Honestly, I think it isn't worth implementing since it would just clutter the manga directory. For now, I'll keep it open to pull request if anyone wants to implement this