From bea38a44b62157979e10fc3ddb5929feea2b2fbb Mon Sep 17 00:00:00 2001 From: "vilda.novak@gmail.com" Date: Mon, 11 Nov 2013 13:18:41 +0000 Subject: [PATCH] last commit fix --- scripts/addons/cam/image_utils.py | 34 ++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/scripts/addons/cam/image_utils.py b/scripts/addons/cam/image_utils.py index 4d5da612..5286cdb4 100644 --- a/scripts/addons/cam/image_utils.py +++ b/scripts/addons/cam/image_utils.py @@ -148,10 +148,12 @@ def numpytoimage(a,iname): a=a.reshape(d) a=a.repeat(4) a[3::4]=1 + #i.pixels=a i.pixels[:]=a[:]#this gives big speedup! print('\ntime '+str(time.time()-t)) return i + def imagetonumpy(i): t=time.time() inc=0 @@ -162,13 +164,39 @@ def imagetonumpy(i): y=0 count=0 na=numpy.array((0.1),dtype=float) - if True:#bpy.app.debug_value==5: + if True: size=width*height na.resize(size*4) id=0 + #print(i.pixels[0]) na[:]=i.pixels[:] - na=na.reshape(width,height,4) - na=na[...,1] + #print(i.pixels[:20]) + na=na[::4] + na=na.reshape(height,width) + na=na.swapaxes(0,1) + #print(na) + #na=na[...,1] + else: + na.resize(width,height) + #na=numpy.array(i.pixels) + percent=0 + id=0 + #progress(len(i.pixels)) + #progress + for v in i.pixels: + if inc==0: + if x==width: + x=0 + y+=1 + #if int(y/height*100)>percent: + #percent=int(y/height*100) + #progress('zbuffer conversion',percent) + na[x,y]=v + #na.itemset(x,y,v) + x+=1 + inc+=1; + if inc==4: + inc=0 print('\ntime '+str(time.time()-t)) return na