def processFrame(number, inDir, inFile, outDir, outFileType, fileType): #print('{} {} {} {}'.format(number,inFile,outDir,outFileType)) # Read a camera raw, crop and write out to a tiff buf = oiio.ImageBuf(inDir + '/' + inFile) spec = buf.spec() print('wxh {} {}'.format(spec.width, spec.height)) cropped = oiio.ImageBuf() oiio.ImageBufAlgo.resize(cropped, buf, roi=oiio.ROI(0, spec.width / 4, 0, spec.height / 4, 0, 1, 0, 3)) #cropped.write( inFileName[0:inFileName.find('.') ]+'.png') borderSize = 50 final = oiio.ImageBuf( oiio.ImageSpec((spec.width / 4) + borderSize, (spec.height / 4) + (borderSize), 3, oiio.FLOAT)) oiio.ImageBufAlgo.fill(final, [0.1, 0.1, 0.1]) oiio.ImageBufAlgo.paste(final, borderSize / 2, borderSize / 2, 0, 0, cropped) oiio.ImageBufAlgo.render_text(final, borderSize / 2, 20, "Show : Inferno : Shot 01", 20, "OpenSans-Bold") frame = 'Frame {0:05d} File {1}'.format(number, inFile) oiio.ImageBufAlgo.render_text(final, borderSize / 2, (spec.height / 4) + borderSize - 5, frame, 20, "OpenSans-Bold") final.write(outDir + '/' + inFile[0:inFile.find('.' + fileType)] + '.' + outFileType) print('Writing {}'.format(outDir + '/' + inFile[0:inFile.find('.' + fileType)] + '.' + outFileType))
def get_rawpixels_from_file(filename, scale_image=1): """ Using OpenImageIO get raw pixels from an image file for previewing purposes (uint8). """ import math # TODO: Migrate it outside callbacks.py try: import OpenImageIO as oiio except: print "Cant' find OpenImageIO." return None, None, None source = oiio.ImageBuf(str(filename)) if not source: return None, None, None # OIIO to get raw uint pixels rgb w = int(math.ceil(source.oriented_width * scale_image)) h = int(math.ceil(source.oriented_height * scale_image)) dest = oiio.ImageBuf(oiio.ImageSpec(w, h, 3, oiio.UINT8)) # DeLinearize optionally if source.spec().format in (oiio.TypeDesc(oiio.HALF), oiio.TypeDesc(oiio.FLOAT)): oiio.ImageBufAlgo.colorconvert(source, source, "linear", "sRGB") dest.copy(source, oiio.UINT8) roi = oiio.ROI(0, w, 0, h, 0, 1, 0, 3) pixels = dest.get_pixels(oiio.UINT8, roi) return pixels, w, h
def NumpyArrayToImageBuf(self): """ Converts a np.ndarray to an OIIO ImageBuf image. :returns: ``oiio.ImageBuf`` object """ height, width = self._img.shape[:2] spec = oiio.ImageSpec(width, height, 4, "uint16") buf = oiio.ImageBuf(spec) buf.set_pixels(oiio.ROI(), self._img) return buf
def third_tiles(buf): third_x = buf.roi.width // 3 third_y = buf.roi.height // 3 for yoffset in range(3): ybegin = buf.roi.ybegin + yoffset * third_y yend = ybegin + third_y for xoffset in range(3): xbegin = buf.roi.xbegin + xoffset * third_x xend = xbegin + third_x tile_roi = oiio.ROI(xbegin, xend, ybegin, yend) yield oiio.ImageBufAlgo.crop(buf, tile_roi)
def toQImage(self, filepath): ibuf = ImageBuf(filepath) try: bufok = ibuf.read(subimage=0, miplevel=0, force=True, convert=oiio.UINT8) except Exception as ex: print(ex) return None if not bufok: return None spec = ibuf.spec() width = spec.width height = spec.height # Expect the channel to be RGB from the beginning. # It might not work if it is a format like ARGB. # qimage = QtGui.QImage(width, height, QtGui.QImage.Format_RGB888) roi = oiio.ROI(0, width, 0, height, 0, 1, 0, 3) try: orgimg = Image.fromarray(ibuf.get_pixels(oiio.UINT8, roi)) # for ImageQt source format error if orgimg.mode in self.mw.shot.NO_SUPPORT_IMAGEQT: orgimg = orgimg.convert('RGB') if self.mw.thumbnail_bright != self.mw.THUMB_DEFALUT_BRIGHT: eim = ImageEnhance.Brightness(orgimg) orgimg = eim.enhance(self.mw.thumbnail_bright) qimage = ImageQt(orgimg) # workaround https://bugreports.qt.io/browse/PYSIDE-884 # output QImage to a file and reRead qimage wksavepath = QStandardPaths.writableLocation( QStandardPaths.TempLocation) wksavepath = wksavepath + "/{0}/sequencegrab.jpg".format( self.mw.APPID) qimage.save(wksavepath, "jpg") wkqim = QImage(wksavepath) qimage = wkqim os.remove(wksavepath) except Exception as ex: print(ex) return None return (qimage)
def OIIOImageBufferFromOpenCVImageBuffer(opencvImageBuffer): (height, width, channels) = opencvImageBuffer.shape npChanneltype = opencvImageBuffer.dtype #print( "OIIOImageBufferFromOpenCVImageBuffer", width, height, channels, npChanneltype ) npToArrayBitDepth = { np.dtype('uint8') : 'B', np.dtype('uint16') : 'H', np.dtype('uint32') : 'I', np.dtype('float32') : 'f', np.dtype('float64') : 'd', } npToOIIOBitDepth = { np.dtype('uint8') : oiio.BASETYPE.UINT8, np.dtype('uint16') : oiio.BASETYPE.UINT16, np.dtype('uint32') : oiio.BASETYPE.UINT32, np.dtype('float32') : oiio.BASETYPE.FLOAT, np.dtype('float64') : oiio.BASETYPE.DOUBLE, } # Support this when oiio more directly integrates with numpy # np.dtype('float16') : oiio.BASETYPE.HALF, if (npChanneltype in npToArrayBitDepth and npChanneltype in npToOIIOBitDepth): arrayChannelType = npToArrayBitDepth[npChanneltype] oiioChanneltype = npToOIIOBitDepth[npChanneltype] else: print( "opencv to oiio - Using fallback bit depth" ) arrayChannelType = 'f' oiioChanneltype = oiio.BASETYPE.FLOAT spec = ImageSpec(width, height, channels, oiioChanneltype) oiioImageBuffer = ImageBuf(spec) roi = oiio.ROI(0, width, 0, height, 0, 1, 0, channels) conversion = oiioImageBuffer.set_pixels( roi, array.array(arrayChannelType, opencvImageBuffer.flatten()) ) if not conversion: print( "opencv to oiio - Error converting the OpenCV buffer to an OpenImageIO buffer" ) oiioImageBuffer = None return oiioImageBuffer
print "miplevel:", b.miplevel, " / ", b.nmiplevels print "channels:", b.nchannels print "name:", b.name print "file_format_name:", b.file_format_name print "deep:", b.deep print "orientation:", b.orientation print "oriented x,y,width,height:", b.oriented_x, b.oriented_y, b.oriented_width, b.oriented_height print "oriented full x,y,width,height:", b.oriented_full_x, b.oriented_full_y, b.oriented_full_width, b.oriented_full_height print "xyz beg/end:", b.xbegin, b.xend, b.ybegin, b.yend, b.zbegin, b.zend print "xyz min/max:", b.xmin, b.xmax, b.ymin, b.ymax, b.zmin, b.zmax print "setting full res..." b.set_full(0, 2048, 0, 2048, 0, 1) print "roi =", b.roi print "full roi =", b.roi_full print "setting full roi again, as ROI..." b.roi_full = oiio.ROI(0, 1024, 0, 1024, 0, 1, 0, b.nchannels) print "Printing the whole spec to be sure:" print_imagespec(b.spec()) print "" print "Resetting to a different MIP level:" b.reset("../common/textures/grid.tx", 0, 2) print_imagespec(b.spec()) print "" # Create a small buffer, do various pixel reads and writes print "Making 2x2 RGB image:" b = oiio.ImageBuf(oiio.ImageSpec(2, 2, 3, oiio.UINT8)) print_imagespec(b.spec()) b.setpixel(0, 0, 0, (1.0, 0.0, 0.0)) b.setpixel(1, 0, 0, (0.0, 1.0, 0.0)) b.setpixel(0, 1, 0, (0.0, 0.0, 1.0))
print ("s['delfoo_str'] =", s['delfoo_str']) print () print ("extra_attribs size is", len(s.extra_attribs)) for i in range(len(s.extra_attribs)) : print (i, s.extra_attribs[i].name, s.extra_attribs[i].type, s.extra_attribs[i].value) print (s.metadata_val (s.extra_attribs[i], True)) print () print ("seralize(xml):") print (s.serialize("xml")) print ("serialize(text, human):") print (s.serialize("text", "detailedhuman")) # test initialization from ROI print ("Testing construction from ROI:") sroi = oiio.ImageSpec (oiio.ROI(0,640,0,480,0,1,0,3), oiio.FLOAT); print_imagespec (sroi) # Also test global OIIO functions here print ("\nTesting global attribute store/retrieve:") oiio.attribute ("plugin_searchpath", "perfect") print ("get_string_attribute plugin_searchpath : ", oiio.get_string_attribute ("plugin_searchpath", "bad")) print ("get_int_attribute plugin_searchpath : ", oiio.get_int_attribute ("plugin_searchpath", 0)) print ("getattribute TypeString plugin_searchpath : ", oiio.getattribute ("plugin_searchpath", oiio.TypeDesc.TypeString)) print ("getattribute TypeFloat plugin_searchpath : ", oiio.getattribute ("plugin_searchpath", oiio.TypeDesc.TypeFloat)) print ("getattribute TypeString blahblah : ", oiio.getattribute ("blahblah", oiio.TypeDesc.TypeString)) print ("Done.") except Exception as detail: print ("Unknown exception:", detail)
print "miplevel:", b.miplevel, " / ", b.nmiplevels print "channels:", b.nchannels print "name:", b.name print "file_format_name:", b.file_format_name print "deep:", b.deep print "orientation:", b.orientation print "oriented x,y,width,height:", b.oriented_x, b.oriented_y, b.oriented_width, b.oriented_height print "oriented full x,y,width,height:", b.oriented_full_x, b.oriented_full_y, b.oriented_full_width, b.oriented_full_height print "xyz beg/end:", b.xbegin, b.xend, b.ybegin, b.yend, b.zbegin, b.zend print "xyz min/max:", b.xmin, b.xmax, b.ymin, b.ymax, b.zmin, b.zmax print "setting full res..." b.set_full (0, 2048, 0, 2048, 0, 1) print "roi =", b.roi print "full roi =", b.roi_full print "setting full roi again, as ROI..." b.roi_full = oiio.ROI(0, 1024, 0, 1024, 0, 1, 0, b.nchannels) print "Printing the whole spec to be sure:" print_imagespec (b.spec()) print "" print "Resetting to a different MIP level:" b.reset ("../common/textures/grid.tx", 0, 2) print_imagespec (b.spec()) print "" # Create a small buffer, do various pixel reads and writes print "Making 2x2 RGB image:" b = oiio.ImageBuf (oiio.ImageSpec(2,2,3,oiio.UINT8)) print_imagespec (b.spec()) b.setpixel (0, 0, 0, (1.0, 0.0, 0.0)) b.setpixel (1, 0, 0, (0.0, 1.0, 0.0)) b.setpixel (0, 1, 0, (0.0, 0.0, 1.0))
def placeImages(res = {}, shotgunData = True, task ='compo_comp', cutOrderSeq =[], imgh= 2294, masterBuf = oiio.ImageBuf(), printFormat = False, ncol = 13, nrow = 5, space =40, maxwidth=2048, maxheight=858, averageList = []): offsetwidth = 0 offsetheight = 0 nbimage = 0 cutOrderSeqLen = len(cutOrderSeq) outLoop = 1 for i in range(1, ncol + 1): if outLoop == 0: break imgw = 578 for j in range(1, nrow + 1): xPos = imgw + (j * space) # placement of the image in x yPos = imgh + (i * space) # placement of the image in y if nbimage < cutOrderSeqLen and nbimage <= (nrow * ncol): shot = cutOrderSeq[nbimage] pathFile = res[shot]['framePath'] fileFromList = oiio.ImageBuf() # if it's a quicktime movie if res[shot]['imgFormat'] == '.quicktime': fileFromList = oiio.ImageBuf(pathFile, res[shot]['cutMid'], 0) else: if not os.path.isfile(pathFile.replace('%04d', str(res[shot]['cutMid']).zfill(4))): dirPath = pathFile[:pathFile.rfind('/')] dirFiles = sorted(os.listdir(dirPath)) fileFromList = oiio.ImageBuf(dirPath + '/' + dirFiles[0]) else: fileFromList = oiio.ImageBuf(pathFile.replace('%04d', str(res[shot]['cutMid']).zfill(4))) else: # fileFromList = text outLoop = 0 break fileFromListWidth = fileFromList.spec().width fileFromListHeight = fileFromList.spec().height if fileFromListWidth > maxwidth or fileFromListHeight > maxheight: tmpInfile = oiio.ImageBuf(oiio.ImageSpec(maxwidth, maxheight, 3, oiio.FLOAT)) offsetwidth = (fileFromListWidth - maxwidth) / 2 offsetheight = (fileFromListHeight - maxheight) / 2 oiio.ImageBufAlgo.crop(tmpInfile, fileFromList, oiio.ROI(offsetwidth, fileFromListWidth - offsetwidth, offsetheight, fileFromListHeight - offsetheight)) fileFromList = tmpInfile stats = oiio.PixelStats() if res[shot]['imgFormat'] == '.exr' and format != 'exr': oiio.ImageBufAlgo.colorconvert(fileFromList, fileFromList, 'linear', 'Asterix2_Film') if printFormat: oiio.ImageBufAlgo.computePixelStats(fileFromList, stats) averageList.append(stats.avg) oiio.ImageBufAlgo.paste(masterBuf, xPos, yPos, 0, 0, fileFromList) # if user want to display shotgun data if shotgunData: shotText = shot taskText = res[shot]['Task'] if taskText != task: oiio.ImageBufAlgo.fill(masterBuf, (1, 0, 0), oiio.ROI(xPos, xPos + maxwidth, yPos - 40, yPos)) oiio.ImageBufAlgo.render_text(masterBuf, xPos + 10, yPos - 10, shotText, 35, _FONT_) oiio.ImageBufAlgo.render_text(masterBuf, xPos + maxwidth - 450, yPos - 10, taskText.upper() + ' v' + str(res[shot]['version']), 35, _FONT_) if taskText == task: statusCol = (1, 0, 0) if res[shot]['status'] == 'cmpt': statusCol = (0, 1, 0) oiio.ImageBufAlgo.fill(masterBuf, statusCol, oiio.ROI(xPos + maxwidth - 50, xPos + maxwidth - 10, yPos - 40, yPos)) imgw = imgw + maxwidth nbimage = nbimage + 1 imgh = imgh + maxheight return masterBuf, averageList
def convertExr( filename='/s/prodanim/asterix2/_sandbox/duda/paintOver/s0180/p0100/s0180_p0100-base-light_prelight-left.0103.exr' ): listImages = [ '/s/prodanim/asterix2/sequences/s0080/s0080_p0010/compo/compo_comp/publish/images/s0080_p0010-base-compo_comp-v026/left/s0080_p0010-base-compo_comp-left.0188.exr', '/s/prodanim/asterix2/sequences/s0080/s0080_p0020/compo/compo_comp/publish/images/s0080_p0020-base-compo_comp-v030/left/s0080_p0020-base-compo_comp-left.0101.exr', '/s/prodanim/asterix2/sequences/s0080/s0080_p0030/compo/compo_comp/publish/images/s0080_p0030-base-compo_comp-v015/left/s0080_p0030-base-compo_comp-left.0101.exr', '/s/prodanim/asterix2/sequences/s0080/s0080_p0040/compo/compo_comp/publish/images/s0080_p0040-base-compo_comp-v020/left/s0080_p0040-base-compo_comp-left.0101.exr', '/s/prodanim/asterix2/sequences/s0080/s0080_p0050/compo/compo_comp/publish/images/s0080_p0050-base-compo_comp-v012/left/s0080_p0050-base-compo_comp-left.0115.exr', '/s/prodanim/asterix2/sequences/s0080/s0080_p0060/compo/compo_comp/publish/images/s0080_p0060-base-compo_comp-v012/left/s0080_p0060-base-compo_comp-left.0101.exr' ] checkerImage = oiio.ImageBuf( '/s/prodanim/asterix2/_sandbox/duda/images/chekerCrop.jpg') widthChecker = checkerImage.spec().width heightChecker = checkerImage.spec().height outFilename = filename.replace('.exr', '.jpg') averageList = [] print outFilename space = 80 maxwidth = 2048 maxheight = 858 nrow = 5 # calcul the number of column ncol = (len(listImages) / nrow) floatncol = (len(listImages) / 5.0) if floatncol - ncol > 0: ncol = ncol + 1 ncol = 14 # inFile = oiio.ImageBuf(filename) # inFileMono = oiio.ImageBuf() # inFilewidth = inFile.spec().width # inFileheight = inFile.spec().height offsetwidth = 0 offsetheight = 0 widthBufImage = (maxwidth * nrow) + (space * (nrow + 1)) heightBufImage = (maxheight * ncol) + (space * (ncol + 1)) buf = oiio.ImageBuf( oiio.ImageSpec(widthBufImage, heightBufImage, 4, oiio.FLOAT)) text = oiio.ImageBuf(oiio.ImageSpec(maxwidth, maxheight, 4, oiio.FLOAT)) oiio.ImageBufAlgo.render_text(text, 100, (maxheight / 2) + 200, 's0080', 700, fontname='LiberationSans-Italic', textcolor=(1, 1, 1, 1)) # if inFilewidth > maxwidth: # offsetwidth = (inFilewidth - maxwidth)/2 # if inFileheight > maxheight: # offsetheight = (inFileheight-maxheight)/2 # tmpInfile = oiio.ImageBuf(oiio.ImageSpec(maxwidth,maxheight,4,oiio.FLOAT)) # oiio.ImageBufAlgo.crop(tmpInfile,inFile,oiio.ROI(offsetwidth,inFile.spec().width-offsetwidth,offsetheight,inFile.spec().height-offsetheight)) imgh = 0 nbimage = 0 listImagesLen = len(listImages) a = 1 for i in range(1, ncol + 1): if a == 0: break imgw = 0 for j in range(1, nrow + 1): if nbimage < listImagesLen: fileFromList = oiio.ImageBuf(listImages[nbimage]) else: #fileFromList = text a = 0 break fileFromListWidth = fileFromList.spec().width fileFromListHeight = fileFromList.spec().height if fileFromListWidth > maxwidth or fileFromListHeight > maxheight: offsetwidth = (fileFromListWidth - maxwidth) / 2 offsetheight = (fileFromListHeight - maxheight) / 2 tmpInfile = oiio.ImageBuf( oiio.ImageSpec(maxwidth, maxheight, 4, oiio.FLOAT)) oiio.ImageBufAlgo.crop( tmpInfile, fileFromList, oiio.ROI(offsetwidth, fileFromListWidth - offsetwidth, offsetheight, fileFromListHeight - offsetheight)) oiio.ImageBufAlgo.paste(buf, imgw + (j * space), imgh + (i * space), 0, 0, tmpInfile) stats = oiio.PixelStats() oiio.ImageBufAlgo.computePixelStats(tmpInfile, stats) averageList.append(stats.avg) imgw = imgw + maxwidth nbimage = nbimage + 1 imgh = imgh + maxheight # create the master buffer masterBufwidth = widthBufImage + (578 * 2) #masterBufHeight = heightBufImage+240+(2*maxheight) masterBufHeight = int(masterBufwidth * 1.414) masterBuf = oiio.ImageBuf( oiio.ImageSpec(masterBufwidth, masterBufHeight, 4, oiio.FLOAT)) #create the white border oiio.ImageBufAlgo.render_box(masterBuf, 518, 518, masterBufwidth - 518, masterBufHeight - 518, (1, 1, 1, 1), True) oiio.ImageBufAlgo.render_box(masterBuf, 578, 578, masterBufwidth - 578, masterBufHeight - 578, (0, 0, 0, 1), True) # #create the bottom ant top band # oiio.ImageBufAlgo.render_box(masterBuf, 120, masterBufHeight-(120+ space+maxheight), masterBufwidth -120, masterBufHeight - 120, (0, 0, 0, 1), True) # oiio.ImageBufAlgo.render_box(masterBuf, 120, 120, masterBufwidth - 120, maxheight+ 120, (0, 0, 0, 1), True) # # #paste the contactsheet images oiio.ImageBufAlgo.paste(masterBuf, 578, 578 + (2 * maxheight), 0, 0, buf) oiio.ImageBufAlgo.render_box(masterBuf, 578, (578 + (2 * maxheight)) - 60, masterBufwidth - 578, 578 + (2 * maxheight), (1, 1, 1, 1), True) # #paste the sequence number oiio.ImageBufAlgo.paste(masterBuf, 840, 120, 0, 0, text) # #startcolumnBox = masterBufHeight - (578+space) - (maxheight/2) -100 startcolumnBox = 878 + (space) endColumnBox = startcolumnBox + 200 startRowBox = 578 + (2 * space) averageScene = (0, 0, 0) for col in averageList: averageScene = tuple(map(sum, zip(averageScene, col))) oiio.ImageBufAlgo.fill( masterBuf, col, oiio.ROI(startRowBox, startRowBox + 200, startcolumnBox, endColumnBox)) startRowBox = startRowBox + 200 if startRowBox > masterBufwidth - (578 + (4 * space) + (2 * widthChecker)): startRowBox = 578 + (space) startcolumnBox = (878) + 200 + int(space * 1.5) endColumnBox = startcolumnBox + 200 averageScene = tuple([x / len(listImages) for x in averageScene]) #oiio.ImageBufAlgo.fill(masterBuf, averageScene, oiio.ROI(578+space, startRowBox, startcolumnBox+200, endColumnBox+200)) oiio.ImageBufAlgo.fill( masterBuf, averageScene, oiio.ROI(masterBufwidth - ((2 * widthChecker) + 578 + (space * 2)), masterBufwidth - (widthChecker + 578 + (2 * space)), 878 + space, 878 + space + heightChecker)) #convert the colorspace oiio.ImageBufAlgo.colorconvert(masterBuf, masterBuf, 'linear', 'Asterix2_Film') oiio.ImageBufAlgo.paste(masterBuf, masterBufwidth - (widthChecker + 578 + space), 878 + space, 0, 0, checkerImage) #convert to asterix lut #oiio.ImageBufAlgo.colorconvert(inFile,inFile,'linear','Asterix2_Film') #create a single channel buffer #oiio.ImageBufAlgo.channels(inFileMono,inFile,("R",)) #stats = oiio.PixelStats() #get the stats fronm buffer #oiio.ImageBufAlgo.computePixelStats(inFileMono,stats) #oiio.ImageBufAlgo.computePixelStats(inFile, stats) #print stats.avg # reelOut = oiio.ImageBuf() # oiio.ImageBufAlgo.channels(reelOut,inFile,(0,1,2)) #oiio.ImageBufAlgo.zero(inFileMono) #inFile.set_write_format(oiio.UINT16) masterBuf.set_write_format(oiio.UINT8) #draw a shape on image #oiio.ImageBufAlgo.render_box(inFile,500,1600,300,1000,(1,1,1,1),True) #inFile.write(outFilename) masterBuf.write( '/s/prodanim/asterix2/_sandbox/duda/paintOver/s0180/p0100/test.jpg')
def contactSheet(task='compo_comp', seq='s0180', res={}, format='jpg', scale='full', shotgunData=True, printFormat=False): path = _OUTPATH_ + '/' + seq + '/' + task + '/' if not os.path.isdir(path): os.makedirs(path) outdir = path + 'contactSheet_' + seq + '.' + format if printFormat: outdir = path + 'contactSheet_print_' + seq + '.' + format cutOrderSeq = getOrder(res) #import the colorchart if in printFormat mode if printFormat: checkerImage = oiio.ImageBuf( '/s/prodanim/asterix2/_sandbox/duda/images/chekerCrop.jpg') widthChecker = checkerImage.spec().width heightChecker = checkerImage.spec().height # list of color average averageList = [] # space in between images space = 80 # max width and height for the images maxwidth = 2048 maxheight = 858 # na color na = oiio.ImageBuf(oiio.ImageSpec(200, 200, 3, oiio.FLOAT)) oiio.ImageBufAlgo.zero(na) oiio.ImageBufAlgo.render_text(na, 20, 140, 'Na', 120, fontname=_FONT_, textcolor=(1, 0, 0, 0)) # logo logo = oiio.ImageBuf( '/s/prodanim/asterix2/_source_global/Software/Nuke/scripts/contactSheetDir/logo.jpg' ) # number of row and column and page (if in printFormat) for the contactsheet nrow = 5 ncol = 0 nbPage = 1 if printFormat: ncol = 13 imbNb = 1 nbPage = 1 for shot in cutOrderSeq: imMod = imbNb % 66 # (ncol*nrow) + 1 if imMod != 0: res[shot]['page'] = nbPage else: nbPage = nbPage + 1 res[shot]['page'] = nbPage imbNb = imbNb + 1 tmpLogo = oiio.ImageBuf(oiio.ImageSpec(1558, 1030, 3, oiio.FLOAT)) oiio.ImageBufAlgo.resize(tmpLogo, logo) logo = tmpLogo else: ncolTmpFloat = float(len(res.keys()) / float(nrow)) ncolTmpInt = int(len(res.keys()) / nrow) if ncolTmpFloat - ncolTmpInt > 0: ncol = ncolTmpInt + 1 else: ncol = ncolTmpInt tmpLogo = oiio.ImageBuf(oiio.ImageSpec(2366, 1544, 3, oiio.FLOAT)) oiio.ImageBufAlgo.resize(tmpLogo, logo) logo = tmpLogo widthLogo = logo.spec().width heightLogo = logo.spec().height # create the master buffer # area containing the images of sequence widthShotArea = (maxwidth * nrow) + (space * (nrow + 1)) heightShotArea = (maxheight * ncol) + (space * (ncol + 1)) masterBufwidth = widthShotArea + (578 * 2) masterBufHeight = int(heightShotArea + (4 * maxheight) + (2 * 578)) if printFormat: masterBufHeight = int(masterBufwidth * 1.414) masterBuf = oiio.ImageBuf( oiio.ImageSpec(masterBufwidth, masterBufHeight, 3, oiio.FLOAT)) # create the white border oiio.ImageBufAlgo.render_box(masterBuf, 518, 518, masterBufwidth - 518, masterBufHeight - 518, (1, 1, 1, 0), True) oiio.ImageBufAlgo.render_box(masterBuf, 578, 578, masterBufwidth - 578, masterBufHeight - 578, (0, 0, 0, 0), True) # top bar oiio.ImageBufAlgo.render_box(masterBuf, 578, (578 + (2 * maxheight)) - 60, masterBufwidth - 578, 578 + (2 * maxheight), (1, 1, 1, 0), True) # bottom bar oiio.ImageBufAlgo.render_box(masterBuf, 578, 578 + heightShotArea + (2 * maxheight), masterBufwidth - 578, 578 + heightShotArea + (2 * maxheight) + 60, (1, 1, 1, 1), True) # adding the task,seq number and logo if printFormat: oiio.ImageBufAlgo.paste(masterBuf, (masterBufwidth / 2) - (widthLogo / 2), 60, 0, 0, logo) else: oiio.ImageBufAlgo.paste(masterBuf, (masterBufwidth / 2) - (widthLogo / 2), 628, 0, 0, logo) oiio.ImageBufAlgo.render_text(masterBuf, int(masterBufwidth / 2) + 200, int(masterBufHeight - (maxheight + 200)), task.upper(), 400, fontname=_FONT_, textcolor=(1, 1, 1, 1)) oiio.ImageBufAlgo.render_text(masterBuf, x=int((masterBufwidth / 2) - (1.35 * maxwidth)), y=int(masterBufHeight - (maxheight + 200)), text=seq, fontsize=1050, fontname=_FONT_, textcolor=(1, 1, 1, 1)) masterBuf, averageList = placeImages(res=res, task=task, cutOrderSeq=cutOrderSeq, imgh=578 + (2 * maxheight), masterBuf=masterBuf, printFormat=printFormat, ncol=ncol, nrow=nrow, space=space, maxwidth=maxwidth, maxheight=maxheight) # # offset to move the image # offsetwidth = 0 # offsetheight = 0 # imgh = 578+(2*maxheight) # nbimage = 0 # cutOrderSeqLen = len(cutOrderSeq) # outLoop =1 # print 'tendering the frames' # for i in range(1, ncol + 1): # if outLoop == 0: # break # imgw = 578 # for j in range(1, nrow + 1): # xPos = imgw + (j * space) # placement of the image in x # yPos = imgh + (i * space) # placement of the image in y # if nbimage < cutOrderSeqLen and nbimage <= (nrow * ncol): # shot = cutOrderSeq[nbimage] # pathFile = res[shot]['framePath'] # fileFromList = oiio.ImageBuf() # # if it's a quicktime movie # if res[shot]['imgFormat'] == '.quicktime': # fileFromList = oiio.ImageBuf(pathFile, res[shot]['cutMid'], 0) # else: # if not os.path.isfile(pathFile.replace('%04d',str(res[shot]['cutMid']).zfill(4))): # dirPath = pathFile[:pathFile.rfind('/')] # dirFiles = sorted(os.listdir(dirPath)) # fileFromList =oiio.ImageBuf(dirPath + '/' +dirFiles[0]) # else: # fileFromList = oiio.ImageBuf(pathFile.replace('%04d',str(res[shot]['cutMid']).zfill(4))) # else: # # fileFromList = text # outLoop = 0 # break # fileFromListWidth = fileFromList.spec().width # fileFromListHeight = fileFromList.spec().height # if fileFromListWidth > maxwidth or fileFromListHeight > maxheight: # tmpInfile = oiio.ImageBuf(oiio.ImageSpec(maxwidth, maxheight, 3, oiio.FLOAT)) # offsetwidth = (fileFromListWidth - maxwidth) / 2 # offsetheight = (fileFromListHeight - maxheight) / 2 # oiio.ImageBufAlgo.crop(tmpInfile, fileFromList,oiio.ROI(offsetwidth, fileFromListWidth - offsetwidth, offsetheight,fileFromListHeight - offsetheight)) # fileFromList = tmpInfile # stats = oiio.PixelStats() # if res[shot]['imgFormat'] == '.exr' and format != 'exr': # oiio.ImageBufAlgo.colorconvert(fileFromList, fileFromList, 'linear', 'Asterix2_Film') # if printFormat: # oiio.ImageBufAlgo.computePixelStats(fileFromList, stats) # averageList.append(stats.avg) # oiio.ImageBufAlgo.paste(masterBuf, xPos, yPos, 0, 0, fileFromList) # # if user want to display shotgun data # if shotgunData: # shotText = shot # taskText = res[shot]['Task'] # if taskText != task: # oiio.ImageBufAlgo.fill(masterBuf,(1,0,0),oiio.ROI(xPos,xPos+maxwidth,yPos-40,yPos)) # oiio.ImageBufAlgo.render_text(masterBuf,xPos +10,yPos-10,shotText,35,_FONT_) # oiio.ImageBufAlgo.render_text(masterBuf, xPos+maxwidth-450, yPos-10, taskText.upper()+' v'+str(res[shot]['version']), 35, _FONT_) # if taskText == task: # statusCol = (1, 0, 0) # if res[shot]['status'] == 'cmpt': # statusCol = (0,1,0) # oiio.ImageBufAlgo.fill(masterBuf,statusCol,oiio.ROI(xPos+maxwidth-50,xPos+maxwidth-10,yPos-40,yPos)) # imgw = imgw + maxwidth # nbimage = nbimage + 1 # imgh = imgh + maxheight print 'adding some salt' # paste the buffer contactsheet in the main buffer #oiio.ImageBufAlgo.paste(masterBuf, 578, 578+(2*maxheight), 0, 0, buf) print 'a bit of pepper' # #paste the sequence number if printFormat: print 'smoldering the lot' # create the average color box startcolumnBox = 1178 + (space) endColumnBox = startcolumnBox + 200 startRowBox = 578 + (2 * space) averageScene = (0, 0, 0) for col in averageList: if len(col) > 2: averageScene = tuple(map(sum, zip(averageScene, col))) oiio.ImageBufAlgo.fill( masterBuf, col, oiio.ROI(startRowBox, startRowBox + 200, startcolumnBox, endColumnBox)) else: oiio.ImageBufAlgo.paste(masterBuf, startRowBox, startcolumnBox, 0, 0, na) startRowBox = startRowBox + 200 if startRowBox > masterBufwidth - (578 + (4 * space) + (2 * widthChecker)): startRowBox = 578 + (2 * space) startcolumnBox = (1178) + 200 + int(space * 1.5) endColumnBox = startcolumnBox + 200 # create the box with the average of scene color averageScene = tuple([x / cutOrderSeqLen for x in averageScene]) oiio.ImageBufAlgo.fill( masterBuf, averageScene, oiio.ROI(masterBufwidth - ((2 * widthChecker) + 578 + (space * 2)), masterBufwidth - (widthChecker + 578 + (2 * space)), 878 + space, 878 + space + heightChecker)) # add the checker and seq text oiio.ImageBufAlgo.paste(masterBuf, masterBufwidth - (widthChecker + 578 + space), 878 + space, 0, 0, checkerImage) #create the output frame output = oiio.ImageBuf() if scale == 'half': output = oiio.ImageBuf( oiio.ImageSpec(int(masterBufwidth / 2), int(masterBufHeight / 2), 3, oiio.FLOAT)) oiio.ImageBufAlgo.resize(output, masterBuf) elif scale == 'quarter': output = oiio.ImageBuf( oiio.ImageSpec(int(masterBufwidth / 4), int(masterBufHeight / 4), 3, oiio.FLOAT)) oiio.ImageBufAlgo.resize(output, masterBuf) else: output = masterBuf bitFormat = oiio.UINT8 if format == 'exr': bitFormat = oiio.HALF elif format == 'tif': bitFormat = oiio.UINT16 else: bitFormat == oiio.UINT8 output.set_write_format(bitFormat) output.write(outdir) print 'and Voila!\n' + outdir + ' is cooked, Enjoy with no moderation!!!!'
def contactSheet(task='compo_comp', seq = 's0180',res={},format = 'jpg',scale = 'full',shotgunData = True, printFormat = False, nrow =5, pdf =True): logoFile = '/s/prodanim/asterix2/_source_global/Software/Nuke/scripts/contactSheetDir/logo.jpg' checkerFile = '/s/prodanim/asterix2/_sandbox/duda/images/chekerCrop.jpg' path = _OUTPATH_+'/'+seq+'/'+task+'/' if not os.path.isdir(path): os.makedirs(path) outdir = path + 'contactSheet_' + seq + '.' + format if printFormat: outdir = path + 'contactSheet_print_' + seq + '.' + format cutOrderSeq = getOrder(res) # space in between images space =80 # max width and height for the images maxwidth = 2048 maxheight = 858 # logo logo = oiio.ImageBuf(logoFile) averageList = [] print 'preparing the sauce' # if in print format if printFormat: # color checker image checkerImage = oiio.ImageBuf(checkerFile) widthChecker = checkerImage.spec().width heightChecker = checkerImage.spec().height # na color na = oiio.ImageBuf(oiio.ImageSpec(200, 200, 3, oiio.FLOAT)) oiio.ImageBufAlgo.zero(na) oiio.ImageBufAlgo.render_text(na, 20, 140, 'Na', 120, fontname=_FONT_, textcolor=(1, 0, 0, 0)) nrow=5 ncol =13 # separate the shot number so there is a maximum of 65 shot per page imbNb = 1 nbPage =1 dictListShot = {} for shot in cutOrderSeq: imMod = imbNb%65 # (ncol*nrow) contactsheet ='contact' + str(nbPage) if imMod != 0: if not contactsheet in dictListShot: dictListShot[contactsheet]={} dictListShot[contactsheet]['listShot'] = [] dictListShot[contactsheet]['masterBuf'] = oiio.ImageBuf() dictListShot[contactsheet]['page'] = nbPage dictListShot[contactsheet]['imagePath']= path + 'contactSheet_print_' + seq + '_'+str(nbPage).zfill(3)+'.' + format dictListShot[contactsheet]['listShot'].append(shot) else: nbPage = nbPage + 1 if not contactsheet in dictListShot: dictListShot[contactsheet] = {} dictListShot[contactsheet]['listShot'] = [] dictListShot[contactsheet]['masterBuf'] = oiio.ImageBuf() dictListShot[contactsheet]['page'] = nbPage dictListShot[contactsheet]['imagePath'] = path + 'contactSheet_print_' + seq + '_' + str(nbPage).zfill(3) + '.' + format dictListShot[contactsheet]['listShot'].append(shot) imbNb = imbNb + 1 # rescale the logo tmpLogo = oiio.ImageBuf(oiio.ImageSpec(1558, 1030, 3, oiio.FLOAT)) oiio.ImageBufAlgo.resize(tmpLogo, logo) logo = tmpLogo widthLogo = logo.spec().width heightLogo = logo.spec().height #create the masterBuffer for contactSheet in sorted(dictListShot.keys()): if contactSheet == 'contact1': dictListShot[contactSheet]['masterBuf'], masterBufwidth, masterBufHeight = createMasterBuf(maxwidth=maxwidth, maxheight=maxheight, printFormat=printFormat, nrow=nrow, ncol=ncol, space=space, seq=seq, task=task, topBar=True, bottomBar=True) oiio.ImageBufAlgo.paste(dictListShot[contactSheet]['masterBuf'], (masterBufwidth / 2) - (widthLogo / 2), 60, 0, 0, logo) #adding page number oiio.ImageBufAlgo.render_text(dictListShot[contactSheet]['masterBuf'], masterBufwidth-650, masterBufHeight -190, str(dictListShot[contactSheet]['page'])+'/'+str(len(dictListShot.keys())), 250, fontname=_FONT_, textcolor=(1, 1, 1, 1)) print 'tendering the frames' dictListShot[contactSheet]['masterBuf'], averageList = placeImages(res=res, task=task, cutOrderSeq=dictListShot[contactSheet]['listShot'], imgh=578 + (2 * maxheight), masterBuf=dictListShot[contactSheet]['masterBuf'], printFormat=printFormat, ncol=ncol, nrow=nrow, space=space, maxwidth=maxwidth, maxheight=maxheight,averageList=averageList, shotgunData=shotgunData) else: dictListShot[contactSheet]['masterBuf'], masterBufwidth, masterBufHeight = createMasterBuf( maxwidth=maxwidth, maxheight=maxheight, printFormat=printFormat, nrow=nrow, ncol=ncol, space=space, seq=seq, task=task, topBar=False, bottomBar=True) # adding page number oiio.ImageBufAlgo.render_text(dictListShot[contactSheet]['masterBuf'], masterBufwidth - 650, masterBufHeight - 190, str(dictListShot[contactSheet]['page']) + '/' + str( len(dictListShot.keys())), 250, fontname=_FONT_, textcolor=(1, 1, 1, 1)) dictListShot[contactSheet]['masterBuf'], averageList = placeImages(res=res, task=task, cutOrderSeq=dictListShot[contactSheet]['listShot'], imgh=578, masterBuf=dictListShot[contactSheet][ 'masterBuf'], printFormat=printFormat, ncol=ncol, nrow=nrow, space=space, maxwidth=maxwidth, maxheight=maxheight,averageList=averageList,shotgunData=shotgunData) # create the average color box startcolumnBox = 1178 + (space) endColumnBox = startcolumnBox + 200 startRowBox = 578 + (2 * space) averageScene = (0, 0, 0) masterBuf = dictListShot['contact1']['masterBuf'] for col in averageList: if len(col) > 2: averageScene = tuple(map(sum, zip(averageScene, col))) oiio.ImageBufAlgo.fill(masterBuf, col, oiio.ROI(startRowBox, startRowBox + 200, startcolumnBox, endColumnBox)) else: oiio.ImageBufAlgo.paste(masterBuf, startRowBox, startcolumnBox, 0, 0, na) startRowBox = startRowBox + 200 if startRowBox > masterBufwidth - (578 + (4 * space) + (2 * widthChecker)): startRowBox = 578 + (2 * space) startcolumnBox = startcolumnBox+ 200 + 10 endColumnBox = startcolumnBox + 200 # create the box with the average of scene color averageScene = tuple([x / len(cutOrderSeq) for x in averageScene]) oiio.ImageBufAlgo.fill(masterBuf, averageScene, oiio.ROI(masterBufwidth - ((2 * widthChecker) + 578 + (space * 2)), masterBufwidth - (widthChecker + 578 + (2 * space)), 878 + space, 878 + space + heightChecker)) # add the checker and seq text oiio.ImageBufAlgo.paste(masterBuf, masterBufwidth - (widthChecker + 578 + space), 878 + space, 0, 0, checkerImage) print 'adding some salt\na bit of pepper\nsmoldering the lot' # create the outputs frame outdir ='' for key in dictListShot.keys(): output = oiio.ImageBuf() if scale == 'half': output = oiio.ImageBuf(oiio.ImageSpec(int(masterBufwidth / 2), int(masterBufHeight / 2), 3, oiio.FLOAT)) oiio.ImageBufAlgo.resize(output, dictListShot[key]['masterBuf']) elif scale == 'quarter': output = oiio.ImageBuf(oiio.ImageSpec(int(masterBufwidth / 4), int(masterBufHeight / 4), 3, oiio.FLOAT)) oiio.ImageBufAlgo.resize(output, dictListShot[key]['masterBuf']) else: output = dictListShot[key]['masterBuf'] bitFormat = oiio.UINT8 if format == 'exr': bitFormat = oiio.HALF elif format == 'tif': bitFormat = oiio.UINT8 else: bitFormat == oiio.UINT8 output.set_write_format(bitFormat) outdir = outdir+ dictListShot[key]['imagePath'] + ', ' output.write(dictListShot[key]['imagePath']) if pdf: #listForPdf = [] #for key in dictListShot: infilePath = dictListShot[key]['imagePath'] if format != 'jpg': infile = oiio.ImageBuf(infilePath) infile.write(infilePath.replace(format,'jpg')) infilePath = infilePath.replace(format,'jpg') #listForPdf.append(dictListShot[key]['imagePath']) pdfFile = Image.open(infilePath) pdfFile.save(infilePath.replace('jpg','pdf')) else: ncolTmpFloat = float(len(res.keys())/float(nrow)) ncolTmpInt = int(len(res.keys())/nrow) if ncolTmpFloat - ncolTmpInt > 0: ncol = ncolTmpInt + 1 else: ncol = ncolTmpInt tmpLogo = oiio.ImageBuf(oiio.ImageSpec(2366, 1544, 3, oiio.FLOAT)) oiio.ImageBufAlgo.resize(tmpLogo, logo) logo = tmpLogo widthLogo = logo.spec().width heightLogo = logo.spec().height masterBuf, masterBufwidth, masterBufHeight = createMasterBuf(maxwidth=maxwidth, maxheight=maxheight, printFormat=printFormat, nrow=nrow, ncol=ncol, space=space, seq=seq, task=task, topBar=True, bottomBar=True) print 'tendering the frames' oiio.ImageBufAlgo.paste(masterBuf, (masterBufwidth / 2) - (widthLogo / 2), 628, 0, 0, logo) masterBuf, averageList = placeImages(res=res, task=task, cutOrderSeq=cutOrderSeq, imgh=578 + (2 * maxheight), masterBuf=masterBuf, printFormat=printFormat, ncol=ncol, nrow=nrow, space=space, maxwidth=maxwidth, maxheight=maxheight, shotgunData=shotgunData) print 'adding some salt\na bit of pepper\nsmoldering the lot' #create the output frame output = oiio.ImageBuf() if scale == 'half': output = oiio.ImageBuf(oiio.ImageSpec(int(masterBufwidth/2), int(masterBufHeight/2), 3, oiio.FLOAT)) oiio.ImageBufAlgo.resize(output,masterBuf) elif scale == 'quarter': output = oiio.ImageBuf(oiio.ImageSpec(int(masterBufwidth / 4), int(masterBufHeight / 4), 3, oiio.FLOAT)) oiio.ImageBufAlgo.resize(output, masterBuf) else: output = masterBuf bitFormat = oiio.UINT8 if format == 'exr': bitFormat = oiio.HALF elif format == 'tif': bitFormat = oiio.UINT16 else: bitFormat == oiio.UINT8 output.set_write_format(bitFormat) output.write(outdir) print 'and Voila!\n'+outdir+' is cooked, \nEnjoy with no moderation!!!!' return outdir
###################################################################### # main test starts here try: # Some handy images to work with gridname = os.path.join(OIIO_TESTSUITE_IMAGEDIR, "grid.tif") grid = ImageBuf(gridname) checker = ImageBuf(ImageSpec(256, 256, 3, oiio.UINT8)) ImageBufAlgo.checker(checker, 8, 8, 8, (0, 0, 0), (1, 1, 1)) gray128 = make_constimage(128, 128, 3, oiio.HALF, (0.5, 0.5, 0.5)) gray64 = make_constimage(64, 64, 3, oiio.HALF, (0.5, 0.5, 0.5)) tahoetiny = ImageBuf(OIIO_TESTSUITE_ROOT + "/common/tahoe-tiny.tif") # black # b = ImageBuf (ImageSpec(320,240,3,oiio.UINT8)) b = ImageBufAlgo.zero(roi=oiio.ROI(0, 320, 0, 240, 0, 1, 0, 3)) write(b, "black.tif", oiio.UINT8) # fill (including use of ROI) b = ImageBuf(ImageSpec(256, 256, 3, oiio.UINT8)) ImageBufAlgo.fill(b, (1, 0.5, 0.5)) ImageBufAlgo.fill(b, (0, 1, 0), oiio.ROI(100, 180, 100, 180)) write(b, "filled.tif", oiio.UINT8) # checker b = ImageBuf(ImageSpec(256, 256, 3, oiio.UINT8)) ImageBufAlgo.checker(b, 64, 64, 64, (1, .5, .5), (.5, 1, .5), 10, 5) write(b, "checker.tif", oiio.UINT8) # noise-uniform b = ImageBufAlgo.noise("white",
#!/usr/bin/env python import OpenImageIO as oiio ###################################################################### # main test starts here try: r = oiio.ROI() print "ROI() =", r print "r.defined =", r.defined r = oiio.ROI(0, 640, 100, 200) print "ROI(0, 640, 100, 200) =", r r = oiio.ROI(0, 640, 0, 480, 0, 1, 0, 4) print "ROI(0, 640, 100, 480, 0, 1, 0, 4) =", r print "r.xbegin =", r.xbegin print "r.xend =", r.xend print "r.ybegin =", r.ybegin print "r.yend =", r.yend print "r.zbegin =", r.zbegin print "r.zend =", r.zend print "r.chbegin =", r.chbegin print "r.chend =", r.chend print "r.defined = ", r.defined print "r.width = ", r.width print "r.height = ", r.height print "r.depth = ", r.depth print "r.nchannels = ", r.nchannels print "r.npixels = ", r.npixels print print "ROI.All =", oiio.ROI.All
def contactSheet(task='compo_comp', seq='s0180', res={}, format='jpg', scale='full', shotgunData=True): path = _OUTPATH_ + '/' + seq + '/' + task + '/' if not os.path.isdir(path): os.makedirs(path) outdir = path + 'contactSheet_' + seq + '.' + format cutOrderSeq = getOrder(res) #import the colorchart checkerImage = oiio.ImageBuf( '/s/prodanim/asterix2/_sandbox/duda/images/chekerCrop.jpg') widthChecker = checkerImage.spec().width heightChecker = checkerImage.spec().height # list of color average averageList = [] # space in between images space = 80 # max width and height for the images maxwidth = 2048 maxheight = 858 # text sequence number text = oiio.ImageBuf( oiio.ImageSpec(int(1.5 * maxwidth), int(1.5 * maxheight), 3, oiio.FLOAT)) oiio.ImageBufAlgo.render_text(text, 100, ((maxheight) / 2) + 400, seq, 1050, fontname=_FONT_, textcolor=(1, 1, 1, 1)) # na color na = oiio.ImageBuf(oiio.ImageSpec(200, 200, 3, oiio.FLOAT)) oiio.ImageBufAlgo.zero(na) oiio.ImageBufAlgo.render_text(na, 20, 140, 'Na', 120, fontname=_FONT_, textcolor=(1, 0, 0, 0)) # logo logo = oiio.ImageBuf( '/s/prodanim/asterix2/_source_global/Software/Nuke/scripts/contactSheetDir/logo.jpg' ) widthLogo = logo.spec().width heightLogo = logo.spec().height # number of row and column for the contactsheet nrow = 5 ncol = 13 # area containing the images of sequence widthBufImage = (maxwidth * nrow) + (space * (nrow + 1)) heightBufImage = (maxheight * ncol) + (space * (ncol + 1)) buf = oiio.ImageBuf( oiio.ImageSpec(widthBufImage, heightBufImage, 3, oiio.FLOAT)) # offset to move the image offsetwidth = 0 offsetheight = 0 imgh = 0 nbimage = 0 cutOrderSeqLen = len(cutOrderSeq) a = 1 print 'tendering the frames' # for i in range(1,ncol+1): # if a == 0: # break imgw = 0 for i in range(1, ncol + 1): if a == 0: break imgw = 0 for j in range(1, nrow + 1): if nbimage < cutOrderSeqLen and nbimage <= (nrow * ncol): shot = cutOrderSeq[nbimage] fileFromList = [] if res[shot]['imgFormat'] == '.quicktime': fileFromList = oiio.ImageBuf(res[shot]['framePath'], res[shot]['cutMid'], 0) else: fileFromList = oiio.ImageBuf( res[shot]['framePath'].replace( '%04d', str(res[shot]['cutMid']).zfill(4))) else: # fileFromList = text a = 0 break fileFromListWidth = fileFromList.spec().width fileFromListHeight = fileFromList.spec().height if fileFromListWidth > maxwidth or fileFromListHeight > maxheight: offsetwidth = (fileFromListWidth - maxwidth) / 2 offsetheight = (fileFromListHeight - maxheight) / 2 tmpInfile = oiio.ImageBuf( oiio.ImageSpec(maxwidth, maxheight, 3, oiio.FLOAT)) oiio.ImageBufAlgo.crop( tmpInfile, fileFromList, oiio.ROI(offsetwidth, fileFromListWidth - offsetwidth, offsetheight, fileFromListHeight - offsetheight)) stats = oiio.PixelStats() if res[shot]['imgFormat'] == '.exr' and format != 'exr': oiio.ImageBufAlgo.colorconvert(tmpInfile, tmpInfile, 'linear', 'Asterix2_Film') oiio.ImageBufAlgo.computePixelStats(tmpInfile, stats) averageList.append(stats.avg) oiio.ImageBufAlgo.paste(buf, imgw + (j * space), imgh + (i * space), 0, 0, tmpInfile) if shotgunData: tmpData = oiio.ImageBuf( oiio.ImageSpec(maxwidth, 40, 3, oiio.FLOAT)) oiio.ImageBufAlgo.zero(tmpData) shotText = shot taskText = res[shot]['Task'] colorTask = (1, 1, 0, 1) if taskText != task: oiio.ImageBufAlgo.fill(tmpData, (1, 0, 0, 1)) colorTask = (1, 0, 0, 1) oiio.ImageBufAlgo.render_text(tmpData, 10, 28, shotText, 40, _FONT_) oiio.ImageBufAlgo.render_text(tmpData, 400, 28, taskText, 40, _FONT_) oiio.ImageBufAlgo.paste(buf, imgw + (j * space), (imgh - 40) + (i * space), 0, 0, tmpData) imgw = imgw + maxwidth nbimage = nbimage + 1 imgh = imgh + maxheight print 'adding some salt' # create the master buffer masterBufwidth = widthBufImage + (578 * 2) masterBufHeight = int(masterBufwidth * 1.414) masterBuf = oiio.ImageBuf( oiio.ImageSpec(masterBufwidth, masterBufHeight, 3, oiio.FLOAT)) # create the white border oiio.ImageBufAlgo.render_box(masterBuf, 518, 518, masterBufwidth - 518, masterBufHeight - 518, (1, 1, 1, 0), True) oiio.ImageBufAlgo.render_box(masterBuf, 578, 578, masterBufwidth - 578, masterBufHeight - 578, (0, 0, 0, 0), True) # paste the buffer contactsheet in the main buffer oiio.ImageBufAlgo.paste(masterBuf, 578, 578 + (2 * maxheight), 0, 0, buf) oiio.ImageBufAlgo.render_box(masterBuf, 578, (578 + (2 * maxheight)) - 60, masterBufwidth - 578, 578 + (2 * maxheight), (1, 1, 1, 0), True) oiio.ImageBufAlgo.render_box(masterBuf, 578, 578 + heightBufImage + (2 * maxheight), masterBufwidth - 578, 578 + heightBufImage + (2 * maxheight) + 60, (1, 1, 1, 1), True) print 'a bit of peper' # #paste the sequence number oiio.ImageBufAlgo.paste(masterBuf, 840, 120, 0, 0, logo) # # create the average color box startcolumnBox = 1178 + (space) endColumnBox = startcolumnBox + 200 startRowBox = 578 + (2 * space) averageScene = (0, 0, 0) for col in averageList: if len(col) > 2: averageScene = tuple(map(sum, zip(averageScene, col))) oiio.ImageBufAlgo.fill( masterBuf, col, oiio.ROI(startRowBox, startRowBox + 200, startcolumnBox, endColumnBox)) else: oiio.ImageBufAlgo.paste(masterBuf, startRowBox, startcolumnBox, 0, 0, na) startRowBox = startRowBox + 200 if startRowBox > masterBufwidth - (578 + (4 * space) + (2 * widthChecker)): startRowBox = 578 + (2 * space) startcolumnBox = (1178) + 200 + int(space * 1.5) endColumnBox = startcolumnBox + 200 print 'smoldering the lot' # create the box with the average of scene color averageScene = tuple([x / cutOrderSeqLen for x in averageScene]) oiio.ImageBufAlgo.fill( masterBuf, averageScene, oiio.ROI(masterBufwidth - ((2 * widthChecker) + 578 + (space * 2)), masterBufwidth - (widthChecker + 578 + (2 * space)), 878 + space, 878 + space + heightChecker)) # add the checker and seq text oiio.ImageBufAlgo.paste(masterBuf, masterBufwidth - (widthChecker + 578 + space), 878 + space, 0, 0, checkerImage) oiio.ImageBufAlgo.paste( masterBuf, (578 + space) + (masterBufwidth / 2) - maxwidth - 200, masterBufHeight - (518 + space + int(1.5 * maxheight)), 0, 0, text) #create the output frame output = oiio.ImageBuf() if scale == 'half': output = oiio.ImageBuf( oiio.ImageSpec(int(masterBufwidth / 2), int(masterBufHeight / 2), 3, oiio.FLOAT)) oiio.ImageBufAlgo.resize(output, masterBuf) elif scale == 'quarter': output = oiio.ImageBuf( oiio.ImageSpec(int(masterBufwidth / 4), int(masterBufHeight / 4), 3, oiio.FLOAT)) oiio.ImageBufAlgo.resize(output, masterBuf) else: output = masterBuf bitFormat = oiio.UINT8 if format == 'exr': bitFormat = oiio.HALF elif format == 'tif': bitFormat = oiio.UINT16 else: bitFormat == oiio.UINT8 output.set_write_format(bitFormat) output.write(outdir) print 'and Voila!\n' + outdir + ' is cooked'
###################################################################### # main test starts here try: # Some handy images to work with gridname = os.path.join(OIIO_TESTSUITE_IMAGEDIR, "grid.tif") grid = ImageBuf (gridname) checker = ImageBuf(ImageSpec(256, 256, 3, oiio.UINT8)) ImageBufAlgo.checker (checker, 8, 8, 8, (0,0,0), (1,1,1)) gray128 = make_constimage (128, 128, 3, oiio.HALF, (0.5,0.5,0.5)) gray64 = make_constimage (64, 64, 3, oiio.HALF, (0.5,0.5,0.5)) tahoetiny = ImageBuf(OIIO_TESTSUITE_ROOT+"/oiiotool/src/tahoe-tiny.tif") # black # b = ImageBuf (ImageSpec(320,240,3,oiio.UINT8)) b = ImageBufAlgo.zero (roi=oiio.ROI(0,320,0,240,0,1,0,3)) write (b, "black.tif", oiio.UINT8) # fill (including use of ROI) b = ImageBuf (ImageSpec(256,256,3,oiio.UINT8)); ImageBufAlgo.fill (b, (1,0.5,0.5)) ImageBufAlgo.fill (b, (0,1,0), oiio.ROI(100,180,100,180)) write (b, "filled.tif", oiio.UINT8) # checker b = ImageBuf (ImageSpec(256,256,3,oiio.UINT8)) ImageBufAlgo.checker (b, 64, 64, 64, (1,.5,.5), (.5,1,.5), 10, 5) write (b, "checker.tif", oiio.UINT8) # noise-uniform b = ImageBufAlgo.noise ("white", 0.25, 0.75, roi=ROI(0,64,0,64,0,1,0,3))
#!/usr/bin/env python from __future__ import print_function from __future__ import absolute_import import OpenImageIO as oiio ###################################################################### # main test starts here try: r = oiio.ROI() print("ROI() =", r) print("r.defined =", r.defined) r = oiio.ROI(0, 640, 100, 200) print("ROI(0, 640, 100, 200) =", r) r = oiio.ROI(0, 640, 0, 480, 0, 1, 0, 4) print("ROI(0, 640, 100, 480, 0, 1, 0, 4) =", r) print("r.xbegin =", r.xbegin) print("r.xend =", r.xend) print("r.ybegin =", r.ybegin) print("r.yend =", r.yend) print("r.zbegin =", r.zbegin) print("r.zend =", r.zend) print("r.chbegin =", r.chbegin) print("r.chend =", r.chend) print("r.defined = ", r.defined) print("r.width = ", r.width) print("r.height = ", r.height) print("r.depth = ", r.depth) print("r.nchannels = ", r.nchannels) print("r.npixels = ", r.npixels)
def createContact(res={}, small=True): framePathRight = res['framePathCompoCompRight'] framePathLeft = res['framePathCompoCompLeft'] cutIn = res['cutIn'] cutOut = res['cutOut'] shotName = res['name'] # set the size of the master buffer masterWidth = 2096 masterHeight = 860 # if the vignette are full frame if not small: masterWidth = masterWidth * 4 masterHeight = masterHeight * 4 # vignette size vignetteWidth = masterWidth / 4 vignetteHeight = masterHeight / 4 # masterbuffer size is 2096x860 masterBufSpec = oiio.ImageSpec(masterWidth, masterHeight, 3, oiio.HALF) vignetteSpec = oiio.ImageSpec(vignetteWidth, vignetteHeight, 3, oiio.HALF) # size of each vignette roi = oiio.ROI(0, vignetteWidth, 0, vignetteHeight) # dictionary for the channels channelDict = { 'd0': (0, 1, 2), 'd1': (4, 5, 6), 'd2': (8, 9, 10), 'd3': (12, 13, 14), 'd4': (16, 17, 18), 'd5': (20, 21, 22), 'd6': (24, 25, 26) } # create a jpg file made of vignettes for frameNb in range(cutIn, cutOut + 1): # position of the vignette in the final image xPos = 0 yPos = 0 # set the size of masterbuff masterBuf = oiio.ImageBuf(masterBufSpec) oiio.ImageBufAlgo.fill(masterBuf, (0, 0, 0)) # convert int to padded str frameNbStr = str(frameNb).zfill(4) # replace the frame nb for the left and right images framePathNbLeft = framePathLeft.replace('%04d', frameNbStr) framePathNbRight = framePathRight.replace('%04d', frameNbStr) print 'Malaxing frame: ' + str(frameNb) frameInLeft = oiio.ImageBuf(framePathNbLeft) frameInRight = oiio.ImageBuf(framePathNbRight) # get rid of extra channels in the di-matte image for key in sorted(channelDict.keys()): #create 2 tmp buffer for extracting the channels and scalind down the image frameTmp = oiio.ImageBuf(vignetteSpec) scaleIn = oiio.ImageBuf(vignetteSpec) # extract the channel from the image oiio.ImageBufAlgo.channels(frameTmp, frameInLeft, channelDict[key]) # if it's the beauty pass (i.e d0) color convert so it's accurate when in jpg if key == 'd0': oiio.ImageBufAlgo.colorconvert(frameTmp, frameTmp, 'linear', 'Asterix2_Film') # scale down the image oiio.ImageBufAlgo.resample(scaleIn, frameTmp, True, roi) # paste the vignette onto the masterbuffer oiio.ImageBufAlgo.paste(masterBuf, xPos, yPos, 0, 0, scaleIn) # increment the pos xPos = xPos + vignetteWidth # redo the above step but for the right image oiio.ImageBufAlgo.channels(frameTmp, frameInRight, channelDict[key]) if key == 'd0': oiio.ImageBufAlgo.colorconvert(frameTmp, frameTmp, 'linear', 'Asterix2_Film') oiio.ImageBufAlgo.resample(scaleIn, frameTmp, True, roi) oiio.ImageBufAlgo.paste(masterBuf, xPos, yPos, 0, 0, scaleIn) # advance xPos and yPos xPos = xPos + vignetteWidth if xPos >= masterWidth: yPos = yPos + vignetteHeight xPos = 0 # write the image path = '/tmp/diTmp/' if not os.path.isdir(path): os.makedirs(path) masterBuf.write(path + 'testdi.' + frameNbStr + '.jpg')
def contactSheet(task='compo_comp', seq='s0180', res={}): # listImages = [ # '/s/prodanim/asterix2/sequences/s0080/s0080_p0010/compo/compo_comp/publish/images/s0080_p0010-base-compo_comp-v026/left/s0080_p0010-base-compo_comp-left.0188.exr', # '/s/prodanim/asterix2/sequences/s0080/s0080_p0020/compo/compo_comp/publish/images/s0080_p0020-base-compo_comp-v030/left/s0080_p0020-base-compo_comp-left.0101.exr', # '/s/prodanim/asterix2/sequences/s0080/s0080_p0030/compo/compo_comp/publish/images/s0080_p0030-base-compo_comp-v015/left/s0080_p0030-base-compo_comp-left.0101.exr', # '/s/prodanim/asterix2/sequences/s0080/s0080_p0040/compo/compo_comp/publish/images/s0080_p0040-base-compo_comp-v020/left/s0080_p0040-base-compo_comp-left.0101.exr', # '/s/prodanim/asterix2/sequences/s0080/s0080_p0050/compo/compo_comp/publish/images/s0080_p0050-base-compo_comp-v012/left/s0080_p0050-base-compo_comp-left.0115.exr', # '/s/prodanim/asterix2/sequences/s0080/s0080_p0060/compo/compo_comp/publish/images/s0080_p0060-base-compo_comp-v012/left/s0080_p0060-base-compo_comp-left.0101.exr' # ] cutOrderSeq = getOrder(res) listImages = [] for shot in cutOrderSeq: if res[shot]['imgFormat'] == '.quicktime': listImages.append(res[shot]['framePath']) else: listImages.append(res[shot]['framePath'].replace( '%04d', str(res[shot]['cutIn']).zfill(4))) print shot, listImages[-1], res[shot]['fInterest'], res[shot]['Task'] #import the colorchart checkerImage = oiio.ImageBuf( '/s/prodanim/asterix2/_sandbox/duda/images/chekerCrop.jpg') widthChecker = checkerImage.spec().width heightChecker = checkerImage.spec().height # list of color average averageList = [] # space in between images space = 80 # max width and height for the images maxwidth = 2048 maxheight = 858 # text sequence number text = oiio.ImageBuf(oiio.ImageSpec(maxwidth, maxheight, 4, oiio.FLOAT)) oiio.ImageBufAlgo.render_text(text, 100, (maxheight / 2) + 200, seq, 700, fontname='LiberationSans-Italic', textcolor=(1, 1, 1, 1)) # na color na = oiio.ImageBuf(oiio.ImageSpec(200, 200, 4, oiio.FLOAT)) oiio.ImageBufAlgo.zero(na) oiio.ImageBufAlgo.render_text(na, 20, 140, 'Na', 120, fontname='LiberationSans-Italic', textcolor=(1, 0, 0, 1)) #number of row and column for the contactsheet nrow = 5 ncol = 14 # area containing the images of sequence widthBufImage = (maxwidth * nrow) + (space * (nrow + 1)) heightBufImage = (maxheight * ncol) + (space * (ncol + 1)) buf = oiio.ImageBuf( oiio.ImageSpec(widthBufImage, heightBufImage, 4, oiio.FLOAT)) # offset to move the image offsetwidth = 0 offsetheight = 0 imgh = 0 nbimage = 0 listImagesLen = len(listImages) a = 1 for i in range(1, ncol + 1): if a == 0: break imgw = 0 for j in range(1, nrow + 1): if nbimage < listImagesLen and nbimage <= (nrow * ncol): fileFromList = [] if listImages[nbimage].rfind('.mov') > 0: fileFromList = oiio.ImageBuf(listImages[nbimage], 1, 0) else: fileFromList = oiio.ImageBuf(listImages[nbimage]) else: #fileFromList = text a = 0 break fileFromListWidth = fileFromList.spec().width fileFromListHeight = fileFromList.spec().height if fileFromListWidth > maxwidth or fileFromListHeight > maxheight: offsetwidth = (fileFromListWidth - maxwidth) / 2 offsetheight = (fileFromListHeight - maxheight) / 2 tmpInfile = oiio.ImageBuf( oiio.ImageSpec(maxwidth, maxheight, 4, oiio.FLOAT)) oiio.ImageBufAlgo.crop( tmpInfile, fileFromList, oiio.ROI(offsetwidth, fileFromListWidth - offsetwidth, offsetheight, fileFromListHeight - offsetheight)) stats = oiio.PixelStats() if listImages[nbimage].rfind('.exr') > 0: oiio.ImageBufAlgo.colorconvert(tmpInfile, tmpInfile, 'linear', 'Asterix2_Film') oiio.ImageBufAlgo.computePixelStats(tmpInfile, stats) averageList.append(stats.avg) oiio.ImageBufAlgo.paste(buf, imgw + (j * space), imgh + (i * space), 0, 0, tmpInfile) imgw = imgw + maxwidth nbimage = nbimage + 1 imgh = imgh + maxheight # create the master buffer masterBufwidth = widthBufImage + (578 * 2) masterBufHeight = int(masterBufwidth * 1.414) masterBuf = oiio.ImageBuf( oiio.ImageSpec(masterBufwidth, masterBufHeight, 4, oiio.FLOAT)) #create the white border oiio.ImageBufAlgo.render_box(masterBuf, 518, 518, masterBufwidth - 518, masterBufHeight - 518, (1, 1, 1, 1), True) oiio.ImageBufAlgo.render_box(masterBuf, 578, 578, masterBufwidth - 578, masterBufHeight - 578, (0, 0, 0, 1), True) # paste the buffer contactsheet in the main buffer oiio.ImageBufAlgo.paste(masterBuf, 578, 578 + (2 * maxheight), 0, 0, buf) oiio.ImageBufAlgo.render_box(masterBuf, 578, (578 + (2 * maxheight)) - 60, masterBufwidth - 578, 578 + (2 * maxheight), (1, 1, 1, 1), True) # #paste the sequence number oiio.ImageBufAlgo.paste(masterBuf, 840, 120, 0, 0, text) # # create the average color box startcolumnBox = 878 + (space) endColumnBox = startcolumnBox + 200 startRowBox = 578 + (2 * space) averageScene = (0, 0, 0) for col in averageList: if len(col) > 2: averageScene = tuple(map(sum, zip(averageScene, col))) oiio.ImageBufAlgo.fill( masterBuf, col, oiio.ROI(startRowBox, startRowBox + 200, startcolumnBox, endColumnBox)) else: oiio.ImageBufAlgo.paste(masterBuf, startRowBox, startcolumnBox, 0, 0, na) startRowBox = startRowBox + 200 if startRowBox > masterBufwidth - (578 + (4 * space) + (2 * widthChecker)): startRowBox = 578 + (2 * space) startcolumnBox = (878) + 200 + int(space * 1.5) endColumnBox = startcolumnBox + 200 # create the box with the average of scene color averageScene = tuple([x / len(listImages) for x in averageScene]) oiio.ImageBufAlgo.fill( masterBuf, averageScene, oiio.ROI(masterBufwidth - ((2 * widthChecker) + 578 + (space * 2)), masterBufwidth - (widthChecker + 578 + (2 * space)), 878 + space, 878 + space + heightChecker)) #convert the colorspace #oiio.ImageBufAlgo.colorconvert(masterBuf,masterBuf,'linear','Asterix2_Film') oiio.ImageBufAlgo.paste(masterBuf, masterBufwidth - (widthChecker + 578 + space), 878 + space, 0, 0, checkerImage) masterBuf.set_write_format(oiio.UINT8) #draw a shape on image #oiio.ImageBufAlgo.render_box(inFile,500,1600,300,1000,(1,1,1,1),True) #inFile.write(outFilename) masterBuf.write( '/s/prodanim/asterix2/_sandbox/duda/paintOver/s0180/p0100/test.jpg')
gridname = "../../../../../oiio-images/grid.tif" grid = ImageBuf(gridname) checker = ImageBuf(ImageSpec(256, 256, 3, oiio.UINT8)) ImageBufAlgo.checker(checker, 8, 8, 8, (0, 0, 0), (1, 1, 1)) gray128 = make_constimage(128, 128, 3, oiio.HALF, (0.5, 0.5, 0.5)) gray64 = make_constimage(64, 64, 3, oiio.HALF, (0.5, 0.5, 0.5)) # black b = ImageBuf(ImageSpec(320, 240, 3, oiio.UINT8)) ImageBufAlgo.zero(b) write(b, "black.tif") # fill (including use of ROI) b = ImageBuf(ImageSpec(256, 256, 3, oiio.UINT8)) ImageBufAlgo.fill(b, (1, 0.5, 0.5)) ImageBufAlgo.fill(b, (0, 1, 0), oiio.ROI(100, 180, 100, 180)) write(b, "filled.tif") # checker b = ImageBuf(ImageSpec(256, 256, 3, oiio.UINT8)) ImageBufAlgo.checker(b, 64, 64, 64, (1, .5, .5), (.5, 1, .5), 10, 5) write(b, "checker.tif") # noise-uniform b = ImageBuf(ImageSpec(64, 64, 3, oiio.UINT8)) ImageBufAlgo.zero(b) ImageBufAlgo.noise(b, "uniform", 0.25, 0.75) write(b, "noise-uniform3.tif") # noise-gaussian b = ImageBuf(ImageSpec(64, 64, 3, oiio.UINT8))
gridname = "../../../../../oiio-images/grid.tif" grid = ImageBuf (gridname) checker = ImageBuf(ImageSpec(256, 256, 3, oiio.UINT8)) ImageBufAlgo.checker (checker, 8, 8, 8, (0,0,0), (1,1,1)) gray128 = make_constimage (128, 128, 3, oiio.HALF, (0.5,0.5,0.5)) gray64 = make_constimage (64, 64, 3, oiio.HALF, (0.5,0.5,0.5)) # black b = ImageBuf (ImageSpec(320,240,3,oiio.UINT8)) ImageBufAlgo.zero (b) write (b, "black.tif") # fill (including use of ROI) b = ImageBuf (ImageSpec(256,256,3,oiio.UINT8)); ImageBufAlgo.fill (b, (1,0.5,0.5)) ImageBufAlgo.fill (b, (0,1,0), oiio.ROI(100,180,100,180)) write (b, "filled.tif") # checker b = ImageBuf (ImageSpec(256,256,3,oiio.UINT8)) ImageBufAlgo.checker (b, 64, 64, 64, (1,.5,.5), (.5,1,.5), 10, 5) write (b, "checker.tif") # noise-uniform b = ImageBuf (ImageSpec(64,64,3,oiio.UINT8)) ImageBufAlgo.zero (b) ImageBufAlgo.noise (b, "uniform", 0.25, 0.75) write (b, "noise-uniform3.tif") # noise-gaussian b = ImageBuf (ImageSpec(64,64,3,oiio.UINT8))
print ("miplevel:", b.miplevel, " / ", b.nmiplevels) print ("channels:", b.nchannels) print ("name:", b.name) print ("file_format_name:", b.file_format_name) print ("deep:", b.deep) print ("orientation:", b.orientation) print ("oriented x,y,width,height:", b.oriented_x, b.oriented_y, b.oriented_width, b.oriented_height) print ("oriented full x,y,width,height:", b.oriented_full_x, b.oriented_full_y, b.oriented_full_width, b.oriented_full_height) print ("xyz beg/end:", b.xbegin, b.xend, b.ybegin, b.yend, b.zbegin, b.zend) print ("xyz min/max:", b.xmin, b.xmax, b.ymin, b.ymax, b.zmin, b.zmax) print ("setting full res...") b.set_full (0, 2048, 0, 2048, 0, 1) print ("roi =", b.roi) print ("full roi =", b.roi_full) print ("setting full roi again, as ROI...") b.roi_full = oiio.ROI(0, 1024, 0, 1024, 0, 1, 0, b.nchannels) print ("Changing origin...") b.set_origin (15, 20); print ("Printing the whole spec to be sure:") print_imagespec (b.spec()) print ("") print ("Resetting to a different MIP level:") b.reset ("../common/textures/grid.tx", 0, 2) print_imagespec (b.spec()) print ("") # Create a small buffer, do various pixel reads and writes print ("Making 2x2 RGB image:") b = oiio.ImageBuf (oiio.ImageSpec(2,2,3,oiio.UINT8)) print_imagespec (b.spec()) b.setpixel (0, 0, 0, (1.0, 0.0, 0.0))
#!/usr/bin/env python from __future__ import print_function from __future__ import absolute_import import OpenImageIO as oiio ###################################################################### # main test starts here try: r = oiio.ROI() print ("ROI() =", r) print ("r.defined =", r.defined) r = oiio.ROI (0, 640, 100, 200) print ("ROI(0, 640, 100, 200) =", r) r = oiio.ROI (0, 640, 0, 480, 0, 1, 0, 4) print ("ROI(0, 640, 100, 480, 0, 1, 0, 4) =", r) print ("r.xbegin =", r.xbegin) print ("r.xend =", r.xend) print ("r.ybegin =", r.ybegin) print ("r.yend =", r.yend) print ("r.zbegin =", r.zbegin) print ("r.zend =", r.zend) print ("r.chbegin =", r.chbegin) print ("r.chend =", r.chend) print ("r.defined = ", r.defined) print ("r.width = ", r.width) print ("r.height = ", r.height)