Python COP crashes at resolution higher that 100x100

   1176   1   0
User Avatar
Member
54 posts
Joined: Sept. 2013
Offline
Hi,

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!
Edited by hektor - Sept. 9, 2020 07:35:05

Attachments:
python_cop_error.PNG (34.4 KB)

User Avatar
Member
54 posts
Joined: Sept. 2013
Offline
Few more screenshots with scale node changing resolution from 100x100 to 200x200. Anything above 100 causing that error



Attachments:
python_cop_error_scale100.PNG (190.9 KB)
python_cop_error_scale200.PNG (165.9 KB)

  • Quick Links