tien_nemo

demo3 push cho anh Dung

......@@ -89,8 +89,8 @@ class OcrController extends Controller
$templateName = $request->get('template_name', '');
// Giả sử file OCR JSON & ảnh nằm trong storage/app/public/image/
$jsonPath = public_path("image/nemo_new_1757393338_with_table.json");
$imgPath = ("image/nemo_new_1757393338.jpg");
$jsonPath = public_path("image/Iwasaki_1757404869_with_table.json");
$imgPath = ("image/Iwasaki_1757404869.jpg");
if (!file_exists($jsonPath)) {
return response()->json(['error' => 'File OCR JSON không tìm thấy'], 404);
......
......@@ -2,7 +2,7 @@ import cv2
import numpy as np
import os
def filter_horizontal_lines(lines_h, img_width, min_h_len_ratio=0.8, tol_y=10):
def filter_horizontal_lines(lines_h, img_width, min_h_len_ratio=0.7, tol_y=10):
if lines_h is None:
return [], []
......@@ -56,7 +56,7 @@ def detect_tables(image_path, gap_threshold=50):
lines_h = cv2.HoughLinesP(edges, 1, np.pi/180, threshold=120,
minLineLength=int(img.shape[1] * 0.6), maxLineGap=20)
img_height, img_width = img.shape[:2]
ys, line_segments = filter_horizontal_lines(lines_h, img_width, min_h_len_ratio=0.8, tol_y=10)
ys, line_segments = filter_horizontal_lines(lines_h, img_width, min_h_len_ratio=0.7, tol_y=10)
total_rows = max(0, len(ys) - 1)
# --- Vertical lines ---
......
......@@ -348,6 +348,7 @@
},
populateTableColumn(field, colIdx) {
// Fill tableForm values from table cells for the given column index, skipping header (row_idx 0)
console.log(`Populating table column for field "${field}" at colIdx:`, colIdx);
this.ensureTableFormSize();
if (!Array.isArray(this.tableInfo)) return;
for (let r = 1; r < this.tableInfo.length; r++) {
......@@ -365,6 +366,8 @@
} else {
this.$set(this.tableForm[dataRowIndex], field, (value || '').toString());
}
console.log(`Row ${dataRowIndex} (${field}):`, value, cell);
}
},
applyTableMappingIfInTable(itemField, bbox) {
......@@ -373,7 +376,6 @@
// Restrict to table fields only
if (!['product_name','product_code','quantity'].includes(itemField)) return false;
const colIdx = this.getColumnIndexForBbox(bbox);
console.log(`Mapping field "${itemField}" to table column index:`, colIdx);
if (colIdx === null || colIdx === undefined) return false;
this.$set(this.tableColumnMapping, itemField, colIdx);
this.populateTableColumn(itemField, colIdx);
......