fix: restore reliable authenticated live recognition
This commit is contained in:
parent
0e23425ef0
commit
934615b593
40 changed files with 2556 additions and 820 deletions
|
|
@ -46,16 +46,21 @@ store = "stock-mediya"
|
|||
shutil.rmtree(store, ignore_errors=True)
|
||||
os.makedirs(store, exist_ok=True)
|
||||
rows = ["SKU_ID,product_name,receipt_date,expiration_date,number_in,number_out,number_on,image_link,price"]
|
||||
written = []
|
||||
for sku, name, indices in PRODUCTS:
|
||||
saved = 0
|
||||
for position, index in enumerate(indices):
|
||||
box = boxes[index]
|
||||
x1, y1, x2, y2 = [int(v) for v in box]
|
||||
crop = image[max(0,y1):y2, max(0,x1):x2]
|
||||
crop = image[max(0, y1):y2, max(0, x1):x2]
|
||||
if crop.size == 0:
|
||||
continue
|
||||
suffix = "" if position == 0 else f"_{position}"
|
||||
suffix = "" if saved == 0 else f"_{saved}"
|
||||
cv2.imwrite(os.path.join(store, f"{sku}{suffix}.jpeg"), crop)
|
||||
saved += 1
|
||||
if saved == 0:
|
||||
raise SystemExit(f"{sku}: no readable crop; refusing a catalog row with no view")
|
||||
written.append(sku)
|
||||
rows.append(f"{sku},{name},2026-09-25,2026-10-20,24,8,16,'',{PRICES[sku]}")
|
||||
open(os.path.join(store, "stock.csv"), "w").write("\n".join(rows) + "\n")
|
||||
print(f"{store}: {len(PRODUCTS)} products, "
|
||||
f"{sum(len(i) for _, _, i in PRODUCTS)} views, csv written")
|
||||
print(f"{store}: {len(written)} products, csv written")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue