forked from screenpipe/screenpipe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ocr.sh
More file actions
executable file
·47 lines (37 loc) · 1.3 KB
/
Copy pathtest_ocr.sh
File metadata and controls
executable file
·47 lines (37 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -e
# Create test image with clear text
convert -size 400x150 xc:white -font DejaVu-Sans -pointsize 32 -fill black -draw "text 20,80 'Hello, Screenpipe OCR'" test_image.png
# Display the image
DISPLAY=:99 display test_image.png &
DISPLAY_PID=$!
# Wait for OCR with retries (up to 60 seconds)
MAX_RETRIES=6
RETRY_INTERVAL=10
OCR_FOUND=false
for i in $(seq 1 $MAX_RETRIES); do
echo "Attempt $i/$MAX_RETRIES: Waiting ${RETRY_INTERVAL}s for OCR..."
sleep $RETRY_INTERVAL
# Show resource usage
ps -p $(cat screenpipe.pid) -o %cpu,%mem,cmd || true
# Check for OCR text
OCR_TEXT=$(sqlite3 $HOME/.screenpipe/db.sqlite "SELECT text FROM ocr_text;" 2>/dev/null || echo "")
if echo "$OCR_TEXT" | grep -qi "Hello, Screenpipe OCR"; then
OCR_FOUND=true
break
fi
# Show what we found so far
echo "OCR text found so far: $(echo "$OCR_TEXT" | head -c 200)"
done
kill $DISPLAY_PID 2>/dev/null || true
if [ "$OCR_FOUND" = true ]; then
echo "OCR test passed: Text was recognized"
else
echo "OCR test failed: Text was not recognized after ${MAX_RETRIES} attempts"
echo "Final OCR text in database:"
sqlite3 $HOME/.screenpipe/db.sqlite "SELECT text FROM ocr_text;" 2>/dev/null | head -20 || echo "(empty)"
echo ""
echo "Last 100 lines of log:"
tail -n 100 screenpipe_output.log
exit 1
fi