From 580439bf8dd33e00f6a668a4828eab01d24d7abf Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Wed, 25 Dec 2024 17:46:41 +0530 Subject: Add image preprocessing before ocr --- src/Chelleport/OCR.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/Chelleport') diff --git a/src/Chelleport/OCR.hs b/src/Chelleport/OCR.hs index ef9dc9e..87cad62 100644 --- a/src/Chelleport/OCR.hs +++ b/src/Chelleport/OCR.hs @@ -30,8 +30,9 @@ instance (MonadIO m) => MonadOCR (AppM m) where threadDelay 20_000 pure path - getWordsInImage filePath = do - liftIO $ findWordCoordinates filePath <* removeFile filePath + getWordsInImage filePath = liftIO $ do + print filePath + findWordCoordinates filePath <* removeFile filePath findWordCoordinates :: String -> IO [OCRMatch] findWordCoordinates imgPath = alloca $ \sizePtr -> do @@ -43,7 +44,7 @@ findWordCoordinates imgPath = alloca $ \sizePtr -> do createTemporaryScreenshot :: DrawContext -> (CInt, CInt) -> (CInt, CInt) -> IO String createTemporaryScreenshot ctx offset size = do - tmpFilePath <- emptySystemTempFile "chelleport-screenshot.png" + tmpFilePath <- emptySystemTempFile "chelleport-screenshot.ppm" screenshot ctx tmpFilePath offset size pure tmpFilePath -- cgit v1.3.1