Open huyuhuster opened 3 years ago
https://github.com/ufo-kit/ufo-filters/blob/d1abb276665ed3b6f59de2b6b0301b08f133115a/src/ufo-memory-in-task.c#L122
I intended to use the memory in mode to read the NumPy buffer just as the example given in UFO tasks docs:
from gi.repository import Ufo import numpy as np import tifffile ref = np.random.random((512, 512)).astype(np.float32) pm = Ufo.PluginManager() g = Ufo.TaskGraph() sched = Ufo.Scheduler() read = pm.get_task('memory-in') write = pm.get_task('write') read.props.pointer = ref.__array_interface__['data'][0] read.props.width = ref.shape[1] read.props.height = ref.shape[0] read.props.number = 1 write.props.filename = 'out.tif' g.connect_nodes(read, write) sched.run(g) out = tifffile.imread('out.tif') assert np.sum(out - ref) == 0.0
But I got a zero value 'out.tif'. Then I debug the code, I found the problem occur at the memcpy where I labeled it. The bytes_per_pixel‘s value equals 0. I try to set bytes_per_pixel‘s value in Python code by:
read.props.bytes_per_pixel = 4
but it doesn't work.
So I try to set it in C codes by hard coded :
priv->bytes_per_pixel = 4
and it works.
The property is called bitdepth not bytes_per_pixel, so read.props.bitdepth = 32 should do the trick.
bitdepth
bytes_per_pixel
read.props.bitdepth = 32
https://github.com/ufo-kit/ufo-filters/blob/d1abb276665ed3b6f59de2b6b0301b08f133115a/src/ufo-memory-in-task.c#L122
I intended to use the memory in mode to read the NumPy buffer just as the example given in UFO tasks docs:
But I got a zero value 'out.tif'. Then I debug the code, I found the problem occur at the memcpy where I labeled it. The bytes_per_pixel‘s value equals 0. I try to set bytes_per_pixel‘s value in Python code by:
read.props.bytes_per_pixel = 4
but it doesn't work.
So I try to set it in C codes by hard coded :
priv->bytes_per_pixel = 4
and it works.