I've been struggling with python COP. Basically, I wrote a simple setRange node. Which remaps min and max value of the image to 0-1 range. Pretty simple. Everything works great at the lower resolution, as soon as the resolution goes above 100x100 I'm getting this error.
Error Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 26, in cook File "C:/PROGRA~1/SideFX/Houdini18.0.460/houdini/python2.7libs\hou.py", line 22583, in setPixelsOfCookingPlane return _hou.CopNode_setPixelsOfCookingPlane(*args, **kwargs) OperationFailed: The attempted operation failed. Invalid sequence/string size
Not sure how to deal with it in this particular case.
import numpy def output_planes_to_cook(cop_node): # This sample only modifies the color plane. return ("C",) def required_input_planes(cop_node, output_plane): # This sample requires the color and alpha planes from the first input. if output_plane == "C": return ("0", "C", "0", "A") return () def cook(cop_node, plane, resolution): assert(plane == "C") input_cop = cop_node.inputs()[0] pixels = numpy.array(input_cop.allPixels("C"), dtype=numpy.float32) pixels = pixels.reshape(input_cop.xRes(), input_cop.yRes(), 3) min = pixels.min() max = pixels.max() d = max - min r = 1.0/d new_pixel = numpy.absolute( (pixels - d) * r ) cop_node.setPixelsOfCookingPlane( new_pixel.reshape(-1).tolist() )
Thanks for any help!