okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
b0fc432ed
main
1"""q36_venc.py EXE MMPROJ MODEL IMG [IMG ...] : drive strata-vision (ENC protocol), print each picture's header + stats.""" 2import subprocess ,sys ,struct ,os 3exe ,mm ,model ,* imgs = sys .argv [1 :] 4args = [exe ,"--mmproj" ,mm ,"--model" ,model ]+ [a for a in os .environ .get ("STRATA_VARGS" ,os .environ .get ("VARGS" ,"" )).split ()if a ] 5p = subprocess .Popen (args ,stdin = subprocess .PIPE ,stdout = subprocess .PIPE ,text = True ) 6p .stdout .readline ().strip ()) 7for img in imgs : 8out = img + ".sve" 9p .stdin .write (f"ENC { img } { out } \n" );p .stdin .flush () 10r = p .stdout .readline ().strip () 11img ,r ) 12if r .startswith ("OK" ): 13d = open (out ,"rb" ).read () 14magic ,n ,nx ,ny ,ne = struct .unpack ("<5i" ,d [:20 ]) 15import array 16a = array .array ("f" );a .frombytes (d [20 :]) 17" hdr" ,hex (magic ),n ,nx ,ny ,ne ,"floats" ,len (a ),"mean %.5f" % (sum (a )/ len (a )),"first" , [round (x ,4 )for x in a [:6 ]]) 18p .stdin .write ("QUIT\n" );p .stdin .flush ();p .wait ()