fix(kamite): revert to constant snip size for Kamite

fixes the snip being too large for larger window widths
This commit is contained in:
Piotr Grabowski 2022-07-12 12:16:06 +02:00
parent 5557af8306
commit 6c0616868b

View file

@ -31,10 +31,10 @@ import (
) )
var ( var (
kamiteRecognizeImageSnipScale = 0.8
kamiteCMDEndpointBaseTpl = "http://localhost:%d/cmd/" kamiteCMDEndpointBaseTpl = "http://localhost:%d/cmd/"
kamiteOCRImageEndpoint = "ocr/image" kamiteOCRImageEndpoint = "ocr/image"
kamiteOCRManualBlockEndpoint = "ocr/manual-block" kamiteOCRManualBlockEndpoint = "ocr/manual-block"
kamiteRecognizeImageSnipDimensionPx = 500
) )
func (app *App) kamiteRecognizeManualBlock() { func (app *App) kamiteRecognizeManualBlock() {
@ -104,7 +104,7 @@ func (app *App) kamiteRecognizeImageUnderCursorBlock() {
srcRowstride := srcPixbuf.GetRowstride() srcRowstride := srcPixbuf.GetRowstride()
// 4. Grab area around the cursor // 4. Grab area around the cursor
snipDim := app.kamiteSnipDimension() snipDim := kamiteRecognizeImageSnipDimensionPx
snipSourceX0, snipSourceY0 := targetX-(snipDim/2), targetY-(snipDim/2) snipSourceX0, snipSourceY0 := targetX-(snipDim/2), targetY-(snipDim/2)
snipBytes := make([]int, snipDim*snipDim) snipBytes := make([]int, snipDim*snipDim)
for y := 0; y < snipDim; y++ { for y := 0; y < snipDim; y++ {
@ -131,11 +131,6 @@ func (app *App) kamiteRecognizeImageUnderCursorBlock() {
) )
} }
func (app *App) kamiteSnipDimension() int {
w, _ := app.getImageAreaInnerSize()
return int(kamiteRecognizeImageSnipScale * float64(w))
}
type KamiteOCRImageCommandParams struct { type KamiteOCRImageCommandParams struct {
Pixels string `json:"pixels"` Pixels string `json:"pixels"`
Width int `json:"width"` Width int `json:"width"`