0% found this document useful (0 votes)
14 views14 pages

Step-by-Step Cursor Installation Guide

Uploaded by

hariimagor
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views14 pages

Step-by-Step Cursor Installation Guide

Uploaded by

hariimagor
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd

rm -rf ~/.

cursor
rm -rf ~/.config/Cursor
rm -rf ~/.local/share/Cursor*
rm -rf ~/.cache/Cursor*
rm -rf ~/Applications/cursor/*
mkdir -p ~/Applications/cursor
sudo rm -f /etc/machine-id
sudo systemd-machine-id-setup
sudo pacman -S macchanger
sudo ip link set wlp0s20f3 down
sudo macchanger -r wlp0s20f3
sudo ip link set wlp0s20f3 up
sudo reboot
sudo reboot
wget -O ~/Applications/cursor/[Link]
"[Link]
85/linux/x64/Cursor-2.1.46-x86_64.AppImage"
chmod +x ~/Applications/cursor/[Link]

[Link]
[Link]
[Link]

[Link]

Awesome—let’s turn this into a calm, step-by-step build plan you can actually follow.
Each step is a small, finishable chunk with clear commands, files to touch, and a
“done” check.

Step-by-Step Build Plan (from zero → demo)


0) Ground rules (scope & success)
• Scope: 2 fixed forms (Business Tax, Land/Sampati). Scan → OCR by regions →
overlay → PDF/print → optional DB save.

• Must-have: CLI app that fills both forms reliably with manual overrides.

• Nice-to-have (later): UI, login, batch mode, speech-to-text.


1) Workspace & environment (Windows)
1. Create project:
C:\Users\user\FirstChild\

2. Python venv & activate:


py -3.11 -m venv .venv

.venv\Scripts\activate

3. Install libs (minimum):


pip install opencv-python pillow pytesseract reportlab numpy pydantic rich
mysql-connector-python

4. Install Tesseract (Windows):

• Install from: UB Mannheim build (you already did).

• Set path for Python:


# in a small test file check_tess.py51 alsa_output.pci-
0000_00_1f.[Link]-output-0 PipeWire s32le 2ch 48000Hz
SUSPENDED
52 alsa_output.pci-0000_00_1f.[Link]-output-3 PipeWire
s32le 8ch 48000Hz SUSPENDED
53 alsa_output.pci-0000_00_1f.[Link]-output-7 PipeWire
s32le 8ch 48000Hz SUSPENDED
54 alsa_output.pci-0000_00_1f.[Link]-output-8 PipeWire
s32le 8ch 48000Hz SUSPENDED
55 alsa_output.pci-0000_00_1f.[Link]-output-9 PipeWire
s32le 8ch 48000Hz SUSPENDED
[npc@arch

import pytesseract

[Link].tesseract_cmd = r"C:\Program Files\Tesseract-


OCR\[Link]"

print(pytesseract.get_tesseract_version())

• Install Nepali lang data if not present (copy [Link] to C:\


Program Files\Tesseract-OCR\tessdata\).

Done when: python check_tess.py prints a version and no error.

2) Repo/files you should have


FirstChild/
[Link]

[Link] (simple placeholder first)

ocr/

__init__.py

[Link]

filler/

__init__.py

[Link]

printer/

__init__.py

[Link]

pdf/

__init__.py

generate_pdf.py

print_utils.py

templates/

business_tax_page1.json

business_tax_page2.json

land_tax_front.json

land_tax_table1.json

assets/

fonts/ (optional devanagari .ttf e.g., [Link])

samples/ (place a couple of scanned test images here)

output/

[Link]

[Link]

3) Templates first (so OCR knows where to look)


• Use the JSON you already generated (from Claude) and split into logical files:

• templates/business_tax_page1.json
• templates/business_tax_page2.json
• templates/land_tax_front.json
• templates/land_tax_table1.json

• Normalize schema (minimal required keys):


{

"form_type": "व्यवसाय कर फारम",

"paper_size_mm": {"width": 210, "height": 297},

"image_dimensions_px": {"width": 847, "height": 1197},

"pixel_to_mm": 0.248,

"fields": [

"field_name": "व्यवसायको नाम",

"field_type": "text_line",

"pixel_bbox": {"x": 220, "y": 558, "width": 585, "height": 25}

// ...

• Keep only pixel_bbox for MVP (you can keep mm for docs, but code reads px).

Done when: all templates load with [Link]() and pass a simple validator.

4) Minimal calibrator (stub now, real later)


• [Link] (MVP): return the template path passed in CLI; later you’ll add
auto-matching & print calibration.
def match_template(image_path: str) -> dict:

raise NotImplementedError("Use --template path directly for MVP.")

Done when: [Link] can import it without breaking.

5) OCR extractor (region-based)


• In ocr/[Link], do:

• Read image (cv2).

• Preprocess: grayscale → bilateral/median blur → adaptive threshold.


• For each field → crop by pixel_bbox →
pytesseract.image_to_string(crop, lang='nep',
config=psm/suggested).

• Return {field_name: value}.

• Optional debug=True → save annotated image with rectangles & values.

Acceptance test: For 3–5 fields in one template, prints non-empty strings.

6) Filler (overlay text onto clean form image)


• In filler/[Link]:

• Load the blank template image or generate a clean white canvas matching
image_dimensions_px.

• For text_line: draw Nepali text with PIL’s ImageDraw using a


Devanagari TTF (blue/bold).

• For box_grid: place characters centered in sub-boxes.

• For signature_box: draw a light frame or paste signature if provided.

• For table_rows: iterate rows if data provided; otherwise leave blank.

Acceptance test: Given a small [Link], the output image shows your strings
exactly in the boxes.

7) PDF export & print helpers


• In pdf/generate_pdf.py:

• Convert the filled NumPy image → PIL → save as PDF via


[Link](..., "PDF").

• Respect target paper size by DPI or size mapping (MVP: 300 DPI; later
you’ll calibrate).

• In pdf/print_utils.py:

• Add a calibration page generator: draw reference crosshairs and a 10mm


grid with labeled axes.
• Later: load a scan of that page and compute offset/scale; store scale_x,
scale_y, offset_x, offset_y in templates/[Link].

Acceptance test: Generated PDF opens and visually matches the positions in the
image.

8) Main orchestrator (CLI)


• Your [Link] should already:

1. Parse: --image, --template, --output, --data (optional), --debug.

2. Load template JSON.

3. Call extract_data_from_image(image, template).

4. Merge with --data overrides.

5. filled = fill_form(image, template, final_data).

6. save_filled_form(filled, output_path) (calls PDF generator


internally).

7. Logs & exceptions with rich or logging.

Acceptance test: One command produces a PDF in ./output with visible filled fields.

Example run:
python [Link] ^

--image assets/samples/business_tax_form_page1.jpg ^

--template templates/business_tax_page1.json ^

--output output/filled_business_tax_page1.pdf ^

--data assets/samples/overrides_business.json ^

--debug

9) Manual correction loop (MVP, CLI)


• Add a --review flag: after OCR, print extracted fields and prompt for quick
edits:
व्यवसायको नाम [DetectedValue]: <user edits or press Enter>

• Saves final merged dict before filling. (No GUI needed.)


Done when: You can fix mis-OCR’d fields in one pass.

10) Database (MySQL, simple & safe)


• Use mysql-connector-python (no C build hassles).

• Schema (minimal):
CREATE TABLE forms (

id INT AUTO_INCREMENT PRIMARY KEY,

form_type VARCHAR(64),

created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP

);

CREATE TABLE form_fields (

id INT AUTO_INCREMENT PRIMARY KEY,

form_id INT,

field_name VARCHAR(128),

field_value TEXT,

FOREIGN KEY (form_id) REFERENCES forms(id)

);

CREATE TABLE outputs (

id INT AUTO_INCREMENT PRIMARY KEY,

form_id INT,

file_path VARCHAR(255),

FOREIGN KEY (form_id) REFERENCES forms(id)

);

• Add --save-db flag: after fill, insert forms, form_fields, outputs.

Acceptance test: Row appears in DB and file_path points to generated PDF.

11) Print alignment (when you’re ready)


• Print [Link] (from print_utils.py) on the same printer you’ll use.

• Manually measure the grid vs printed form boxes (3 reference points).

• Compute:
• scale_x = printed_dx / expected_dx
• scale_y = printed_dy / expected_dy

• offset_x, offset_y (in px at your chosen DPI)

• Store in templates/[Link].

• Apply to every pixel_bbox before drawing:


x' = x*scale_x + offset_x, y' = y*scale_y + offset_y.

Acceptance test: A small field (e.g., PAN box) lands exactly inside the printed boxes.

12) Batch mode (optional)


• Add --batch folder/ to process multiple images with one template; save PDFs
with suffix.

13) Logging & diagnostics


• Use rich for pretty logs:

• Stage markers: LOAD → OCR → MERGE → FILL → EXPORT → SAVE_DB.

• Save debug/annotated_*.png when --debug.

14) Tests you can run today


• OCR sanity: Crop one known field region → ensure image_to_string(...,
lang='nep') returns Devanagari.

• Overlay sanity: Use a fake [Link] to fill the form with known values.

• PDF sanity: The PDF opens and looks identical to PNG export.

• DB sanity: Insert a sample record and fetch it.

15) Daily routine (6 hrs / day)


1. 90 min: Focus task of the day (e.g., extractor refine).

2. 30 min: Write/adjust tests & sample JSON.

3. 60 min: Debug & log improvements (annotated outputs).


4. 60 min: Template mapping refinement (move boxes a few px; re-test).

5. 30 min: Knowledge notes (what worked/failed).

6. 60 min: Next task prep (stubs, TODOs, issues).

7. 30 min: Stretch goal / cleanup.

16) Milestones (what “done” looks like)


• M1: Template-OCR loop works

• Can extract 10+ fields from one page with >70% usable text.

• M2: Fill & Export

• You produce a neat PDF with all field values in right places (visually).

• M3: Manual Review

• You correct 3–5 fields quickly in the CLI and re-export.

• M4: Print alignment

• Your filled text lands inside printed boxes (within 1–2 mm).

• M5: DB logging

• Each run creates a record and file path saved in MySQL.

• M6: Two forms supported

• Both Business Tax & Land/Sampati flow end-to-end.

17) Common pitfalls (and fixes)


• Tesseract path error: Hard-set [Link].tesseract_cmd
to the Windows path.

• Nepali OCR gibberish: Increase contrast, use adaptive threshold, enlarge crop
by ~5–10px margins.

• Fonts not rendering Devanagari: Use a Devanagari TTF (e.g., Noto Sans
Devanagari) via PIL’s [Link].

• PDF size mismatch: Lock DPI (e.g., 300) and paper size; print a calibration page
and correct scale/offset.
• MySQL install pain on Windows: Use mysql-connector-python (pure
Python) not mysqlclient.

18) Final demo script (repeatable)


1. Show input scan → run CLI with --debug → show extracted fields.

2. Edit a field live (--review mode).

3. Generate PDF → open it.

4. (If printer available) print calibrated page → place over form → show alignment.

5. Show DB row created with file path.

If you want, I can also:

• Generate a [Link] you can tick daily.

• Provide a minimal sample template JSON for each form page (sanity checked).

• Add a starter [Link] and code snippet to apply offsets/scales.

High-Level Rule
• 8 hours daily = 4 sessions of 2 hours each.

• Each session has one primary task (no multitasking).

• Log everything → You’ll see progress and stay motivated.

📅 Phase 1: Foundation & Setup (Sept 1–Sept 14)


Goals: Python mastery, OCR basics, MySQL setup, First template
design.
Daily Routine (8 hr split):

1. 2 hr → Python Core Drills

• Variables, loops, functions, error handling.


• Mini-task: Build a CLI contact book storing JSON.

2. 2 hr → Python Advanced / CLI

• argparse (flags, arguments).

• Pathlib, decorators, list/dict comprehensions.

• Mini-task: CLI tool that accepts name + phone and saves to JSON.

3. 2 hr → OCR & Image Processing Basics

• Install & run Tesseract on a test image.

• Use Pillow/OpenCV to crop/threshold.

• Task: Extract “Hello” from a scanned handwritten word.

4. 2 hr → Database & Template JSON

• Install MySQL, learn basic CRUD queries.

• Create JSON schema for Business Tax Form (2–3 fields).

📅 Phase 2: MVP Core (Sept 15–Oct 10)


Goals: Build the app pipeline ([Link], OCR, filler, PDF, DB).
Daily Routine (8 hr split):

1. 2 hr → App Architecture Work

• Write [Link] skeleton with CLI args.

• Integrate modules step by step.

2. 2 hr → OCR Development

• Implement ocr/[Link].

• Test on cropped fields of your form.

3. 2 hr → Auto Fill + PDF

• Write [Link] for placing text in form.

• Write generate_pdf.py to export output.

4. 2 hr → Database Connection
• Store extracted data into MySQL.

• Implement search + update (CRUD).

By Oct 10 → Your MVP should fill Business Tax Form end-to-end.


📅 Phase 3: Expansion & Testing (Oct 11–Nov 1)


Goals: Add more forms, improve OCR accuracy, database fully
integrated.
Daily Routine (8 hr split):

1. 2 hr → Land Tax Form Template

• Define JSON fields + test OCR.

2. 2 hr → Preprocessing for Accuracy

• Experiment with thresholding, grayscale, noise reduction.

• Compare confidence scores.

3. 2 hr → CRUD & Database Testing

• Insert 50 fake entries.

• Test search/update performance.

4. 2 hr → Error Handling & Logging

• Add try/except in all modules.

• Create clean logs for debugging.

📅 Phase 4: Polish & Docs (Nov 2–Nov 15)


Goals: Polish app, prepare report & PPT.
Daily Routine (8 hr split):

1. 2 hr → Code Cleanup

• PEP8 formatting, comments, docstrings.

2. 2 hr → Documentation
• Write README, project proposal update, technical explanation.

3. 2 hr → Slide Preparation

• PPT: Intro → Problem → Solution → Demo → Outcome.

4. 2 hr → Demo Testing

• Run through end-to-end workflows.

• Record fallback demo video.

📅 Phase 5: Defense Prep (Nov 16–Nov 23)


Goals: Be 100% ready for professors’ questions.
Daily Routine (8 hr split):

1. 2 hr → Dry Run of Demo

• Time yourself: 7–10 min presentation.

2. 2 hr → Anticipated Questions

• Answer: Why Python? Why MySQL? Why OCR?

• Counter: What if it fails? What’s new about your project?

3. 2 hr → Slides + Script Refinement

• Ensure clear flow & confident delivery.

4. 2 hr → Backup Preparation

• Screenshots + recorded demo.

• Double-check all references + citations.

🎯 Key Habits
• End every day with “What I built today, what’s next tomorrow”.

• Every Sunday: Review week → Adjust plan.

• Keep tasks visible (Trello/Notion or even a notebook).

You might also like