Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def TCPfin(self,imgprevstr):
- timenow = datetime.now() #get current time
- #quick
- splitimgprevstr = imgprevstr.split(',',11)
- splitimgdata = splitimgprevstr[11] #qstring with 540000 chars
- imgwidth = int(splitimgprevstr[9])
- imgheight = int(splitimgprevstr[10])
- rgbArray = np.zeros((imgwidth,imgheight,3), 'uint8')
- #slow from here
- for ih in range(0,imgheight,1): # takes around 220ms per loop (3 loops for the 3 RGB channels
- for iw in range(0,imgwidth,1):
- curpixelR = splitimgdata.mid(iw*6+ih*imgwidth*6, 2) #get a pair of chars from the qstring
- rgbArray[iw,ih,0] = (curpixelR.toInt(16))[0] #convert the ascii hex qstring into an int
- for ih in range(0,imgheight,1):
- for iw in range(2,imgwidth,1):
- curpixelG = splitimgdata.mid(iw*6+ih*imgwidth*6, 2)
- rgbArray[iw,ih,1] = (curpixelG.toInt(16))[0]
- for ih in range(0,imgheight,1):
- for iw in range(4,imgwidth,1):
- curpixelB = splitimgdata.mid(iw*6+ih*imgwidth*6, 2)
- rgbArray[iw,ih,2] = (curpixelB.toInt(16))[0]
- #Total execution time 656ms
- # quick
- fintime = self.millis(timenow)
- print fintime
- previmg = Image.fromarray(rgbArray)
- previmg = previmg.rotate(90)
- self.parent.slot_testcall(previmg) #image sent to GUI module to update screen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement