Haha, this works great. Performance-wise I couldn't pick up any difference,
though I haven't run through enough tests to be conclusive. The local disks
here are rather quick, but likely it would make more of a difference in a
fully networked environment, or where disks were slow.

The obvious upside is I no longer have to access the disk for intermediate
storage and that's a big win.

---

The next problem is capturing the image without having to worry about
whether something is obscuring the viewport. Like in the good old days (on
Windows and current days on Linux) grabbing the framebuffer also grabs
whatever is in front of the viewport at the time, which means you'll
practically have to give up your machine for the duration of the playblast.

An off-screen option would be ideal, but I'm not sure if that's an option
in this case.

This command needs to somehow access the viewport, without having actually
have it visible; and ideally with cmds.refresh(suspend=True) in action.

image = api.MImage()
view.readColorBuffer(image, True)

- http://nathanhorne.com/?p=261

Any ideas?



On 28 January 2016 at 08:04, Marcus Ottosson <[email protected]> wrote:

> Ah, neat. Thanks, I’ll try this out.
>
> One of the problems of the disk-writing approach in practice was that the
> instant reading and writing of a file is quite unpredictable; as I’m
> overwriting the same file per frame, sometimes it picks up an older image
> several frames back. Assuming network caching or such. This should
> circumvent that.
>
> Could this also be used to create a playblast in 32 bit with the color
> management in Maya 2016?
>
> Dunno, it would depend on the capabilities of both MImage, the
> framegrabbing mechanism and whether 32-bits of pixels are actually stored
> in the framebuffer. It’s the latter where I’m sceptical.
> ​
>
> On 28 January 2016 at 07:15, Justin Israel <[email protected]> wrote:
>
>> Hey Marcus,
>>
>> I did some more searching an found some info about people going from
>> MImage to QImage by passing the pointer.
>>
>> Simplified example:
>> https://gist.github.com/justinfx/bc9a966507211e98cd37
>>
>> Original post:
>>
>> http://tech-artists.org/forum/showthread.php?4547-Passing-uchar-pointer-with-PySide-in-Maya
>>
>> Justin
>>
>>
>> On Thursday, January 28, 2016 at 4:54:27 PM UTC+13, Justin Israel wrote:
>>>
>>>
>>>
>>> On Wed, 27 Jan 2016 11:05 AM Marcus Ottosson <[email protected]>
>>> wrote:
>>>
>>>> Thanks Justin.
>>>>
>>>> I think I got a reasonable version up and running with writing to disk;
>>>> basically per frame write to disk, read it back in, and grab the resulting
>>>> viewports laid out in a grid. The performance overhead wasn’t as bad as I
>>>> had first thought, at least in the expected cases where the majority of
>>>> time is spent calculating the frame itself.
>>>>
>>>> I’m on Linux though and the memory location sounds like a healthy
>>>> optimisation, may also bypass any potential permission issues with writing
>>>> to disk.
>>>>
>>>> The end result at least seems like something many people have been
>>>> looking for, judging by Googling for a solution, to capture all four
>>>> viewports at once in a single go. I’ve had a need for it many times in the
>>>> past, before I knew Python well enough to get it together. I’ll see if I
>>>> can put something shareable together and perhaps crack that nut once and
>>>> for all.
>>>>
>>>> Also, MImage can give you back the raw pixel data
>>>>
>>>> I tried making use of that, do you mean the MImage.pixels() method? I
>>>> got what I assume is a pointer to an array of pixels in memory, but I
>>>> wasn’t sure how to make use of that through Python. That might allow me to
>>>> generate a pixmap directly, as opposed to writing it out first.
>>>>
>>>
>>> I took a look at python options and I couldn't find any support in
>>> OpenImageIO, ImageMagick, or OpenCV bindings that would let you pass a data
>>> pointer (you can convert the swig pixels array from MImage using long())
>>>
>>> I know you could do it from C++
>>>
>>> ​
>>>>
>>>> On 26 January 2016 at 20:59, Justin Israel <[email protected]>
>>>> wrote:
>>>>
>>>>> Hey Marcus,
>>>>>
>>>>> The MImage approach was a way I had also used in the past. I had
>>>>> encountered what you mentioned about the issues grabbing from the pixmap.
>>>>> Seemed to always be black for me as well because of the OpenGL viewport
>>>>> that is embedded, I think?
>>>>>
>>>>> There are a couple options for MImage though. On Linux/OSX there is a
>>>>> shmem/tmpfs location which is a mounted "ram drive". You can write images
>>>>> there and maybe move them elsewhere in a background thread? I don't know
>>>>> what exists for this solution on Windows. Also, MImage can give you back
>>>>> the raw pixel data. Maybe you can make use of it with something like
>>>>> OpenImageIO/ImageMagick/OpenCV, in memory?
>>>>>
>>>>> Justin
>>>>>
>>>>> On Wed, Jan 27, 2016 at 6:17 AM Marcus Ottosson <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Sorry, this was the Nathan Horne address I meant to post.
>>>>>>
>>>>>> - http://nathanhorne.com/?p=261
>>>>>>
>>>>>> On 26 January 2016 at 16:48, Marcus Ottosson <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> I found this.
>>>>>>>
>>>>>>> - http://stackoverflow.com/a/9417180
>>>>>>>
>>>>>>> ..but it doesn't produce anything reliable. Just a black-ish
>>>>>>> picture; like a dump of an arbitrary location in memory.
>>>>>>>
>>>>>>> Saving to a file works however.
>>>>>>>
>>>>>>> - http://nathanhorne.com/?p=485
>>>>>>>
>>>>>>> But it's not ideal..
>>>>>>>
>>>>>>> On 26 January 2016 at 16:33, Marcus Ottosson <[email protected]
>>>>>>> > wrote:
>>>>>>>
>>>>>>>> Hi all,
>>>>>>>>
>>>>>>>> I'm looking to perform a playblast from multiple cameras at once,
>>>>>>>> and they way I was thinking of going at it, was to have four viewports
>>>>>>>> refresh during playback, and capture each viewport into a QPixmap that 
>>>>>>>> I
>>>>>>>> line up, such as in a 4x4 grid, within a single widget and save the
>>>>>>>> resulting image as the "playblast".
>>>>>>>>
>>>>>>>> Does anyone know how to grab a frame from the current viewport? Or
>>>>>>>> know of an existing or more straightforward method to achieve the same
>>>>>>>> result?
>>>>>>>>
>>>>>>>> Best,
>>>>>>>> Marcus
>>>>>>>>
>>>>>>>> --
>>>>>>>> *Marcus Ottosson*
>>>>>>>> [email protected]
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> *Marcus Ottosson*
>>>>>>> [email protected]
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> *Marcus Ottosson*
>>>>>> [email protected]
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Python Programming for Autodesk Maya" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> To view this discussion on the web visit
>>>>>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCUY38zYjNMQT7EGRmJTxYQyXi4-FBbi%2BFtRFwSkM1vUA%40mail.gmail.com
>>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCUY38zYjNMQT7EGRmJTxYQyXi4-FBbi%2BFtRFwSkM1vUA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Python Programming for Autodesk Maya" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>>
>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3MpnYDHm5rQpEhNySw7__r10u5WF81ZDeySOoqXhyeYw%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3MpnYDHm5rQpEhNySw7__r10u5WF81ZDeySOoqXhyeYw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>
>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> *Marcus Ottosson*
>>>> [email protected]
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Python Programming for Autodesk Maya" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOD47FVK2zic%2B34AiBj%2BUENAMrMMfFM0sj4n%2BY7hK_JZ4g%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOD47FVK2zic%2B34AiBj%2BUENAMrMMfFM0sj4n%2BY7hK_JZ4g%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/3699754a-eafa-4e14-b6f6-6bc3837be222%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/3699754a-eafa-4e14-b6f6-6bc3837be222%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> *Marcus Ottosson*
> [email protected]
>



-- 
*Marcus Ottosson*
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODv0gJmSUD3cFet%3DBq2Oxco%2Bq_C2q5etzY9QVqFYZeKeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to