code wiki / (root) / nx_image_search.nx

nx_image_search.nx

buildroot/runtime/nx_image_search.nx

10328 B220 linesdepth 11pulls 52 transitivereach 0 importersview sourcekind tooltopic image
docsdependenciesstructsconstsfunctions

about

nx_image_search.nx -- REUSABLE per-site SEARCH-BY-IMAGE (reverse-image) CLIENT. ONE perceptual-hash engine pointed at ANY site via a data-driven sites registry (Cardinal 11/17). Each site = its OWN durable fingerprint index, so a query is SCOPED to exactly that site BY CONSTRUCTION (site A's index file physically cannot return site B's images). This is the image-side analog of nx_onsite_search (which does text->doc); here we do image->image: "find this image across THIS site's corpus", Yandex/Google/Bing reverse-image style, done sovereignly. Usage: nx_image_search <sites.tsv> <site> <query_gray_path> <w> <h> [threshold] Registry row (TAB-separated, trailing newline required): site<TAB>fp_index_path<TAB>base_url fp_index line (built by nx_image_index / the gate; docid = line number): cid<TAB>dhash_hex16<TAB>ahash_hex16 REUSE not reinvent: dHash/aHash + nearest-fingerprint + 64-bit Hamming all come from nx_phash (Krawetz 2011 / Zauner 2010) -> ZERO new ranking math. The query image is a raw grayscale buffer (w*h u8) so the client stays format-agnostic; the real-corpus path (PNG/JPEG decode -> gray) is a separate ingestor rung. dHash ranks (robust to brightness/recompress/resize); aHash breaks ties. HONEST: this is the FAST near-duplicate tier; semantic "looks-like" needs a trained embedding (later rung). license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_phash.nx nx_itoa_lib.nx nx_image_gray.nx nx_image_search.nx

imports: nx_phash.nxnx_itoa_lib.nxnx_image_gray.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main is_puts is_atoi sys_read_file sys_openat_rd sys_lseek sys_mmap sys_read sys_close is_lookup_site is_streq nx_img_to_gray sys_read_file ↻ nx_jpeg_decode_luma sys_mmap ↻ nx_jpeg_dec_ctx_init sys_mmap ↻ _jpeg_ascii_probe_sof sys_mmap ↻ nx_jpeg_seg_init nx_jpeg_seg_next nx_jpeg_classify_marker nx_jpeg_marker_is_lengthle nx_jpeg_sof_parse nx_jpeg_is_progressive prog_be16 nx_jpeg_prog_decode sys_mmap ↻ prog_be16 ↻ nx_jpeg_dqt_parse nx_jpeg_dht_parse nx_jpeg_dht_build_decode_t nx_jpeg_sos_parse prog_next_marker prog_scan sys_mmap ↻ nx_jpeg_huff_decode_symbol nx_jpeg_ent_extend nx_jpeg_ent_receive prog_refine_nz

structs

none

consts

23const IS_TOP_K: i64 = 5
24const IS_DEFAULT_THRESH: i64 = 10

functions

26func is_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main
27func is_putb(p: *u8, n: i64) -> i64 { if n>0 { sys_write(1,p,n) } return 0 }
called by 1: main
32func is_num(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
33func is_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
34func is_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]!=(0 as u8){return 0} return 1 }
called by 1: is_lookup_site
35func is_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ if s[i]>=(48 as u8){ if s[i]<=(57 as u8){ v=v*10+((s[i]-(48 as u8)) as i64) } } i=i+1 } return v }
called by 1: main
38func is_hexparse(p: *u8) -> i64
called by 1: main
54func is_lookup_site(reg: *u8, n: i64, site: *u8, out_idx: *i64, out_base: *i64) -> i64
called by 1: main calls 1: is_streq
85func main(argc: i64, argv: *i64) -> i64