Replies: 7 comments 8 replies
-
|
Do you have a specific example script that you could share that you feel is slow? I have in the past occasionally helped people get quite good performance saving DNG files, such as here: https://forums.raspberrypi.com/viewtopic.php?t=360334 (sorry, quite a long thread, but we were able to get some pretty blazing speeds using a thread pool and an NVMe drive). My recollection was that you have to avoid using packed or compressed formats. Of course it's extremely sensitive to the speed of whatever disk you're writing too - that Samsung NVMe was just awesome and blew away my SATA SSDs. I don't recall that I thought the speed of PiDNG was an issue, but it was a while ago. We do know the author of PiDNG, and I'm sure he would be amenable to improvements if we could identify any. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your answer, no problems actually with the installed version of PiDNG. It was just a remark about a potential problem with the Github version, there is one more SampleFormat tag and it's normal but the DNG file does not seem correct. I did not investigate further. Nothing urgent in any case. |
Beta Was this translation helpful? Give feedback.
-
|
You might be interested in this new python package that is fairly fast for DNG encode - https://github.com/mu-files/mu-image/tree/main/muimg |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for this reply. That sounds like a great idea. Can you point me to the examples that you distribute (especially any you do with saving DNG) so that I can see the format?
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: davidplowman ***@***.***>
Sent: Tuesday, May 5, 2026 1:13:30 AM
To: raspberrypi/picamera2 ***@***.***>
Cc: mu-files ***@***.***>; Comment ***@***.***>
Subject: Re: [raspberrypi/picamera2] DNG encoding (Discussion #1057)
Hi, and thanks for the info. If you were interested in supplying a "how to save raw camera image using mu-files" example Python script, we'd be very happy to merge and distribute it with our other examples. Do ask if you have any questions about that. Obviously what we have at the moment seems to work well for us, do you think there are any specific benefits that we could point to? Thanks!
—
Reply to this email directly, view it on GitHub<#1057 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BSWFDDBEKOQGPYY3L2S7YCL4ZGPCVAVCNFSM6AAAAACYOTKDRKVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMOBRGM3DINA>.
Triage notifications on the go with GitHub Mobile for iOS<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Sure, there are a number of examples, including this one. However, I might be tempted just to use this code: The print statements at the end show you how to get the metadata associated with that capture (exposure time, colour matrix etc.), the raw image array (without copying it), and the buffer format (do you have a Raspberry Pi of some kind?). Hopefully you can just replace those lines with code that saves a DNG. Please ask if you have any questions! |
Beta Was this translation helpful? Give feedback.
-
|
I uploaded an example here: https://github.com/mu-files/mu-rasppi The important function is write_muimg() in picamera2_capture.py The code also benchmarks PiDNG and muimg on a captured image. I added some details to the README with benchmark results and advantages/disadvantages of each library. Note1: I needed to create a branch of muimg due to python version issues. The tifffile package muimg depends on is at python 3.12 so had to down-version that in the branch. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for doing this, that's very interesting. A few of things to discuss... Firstly, the latest Raspberry Pi OS (Trixie) uses Python 3.13 and numpy 2.2.something, so you shouldn't need any compatibility branches or anything. I've been using the regular versions of everything just fine - maybe just double-check what OS version you have? The latest Raspberry Pi OS may also be using a more recent version of PiDNG. But your benchmarks are still showing approximately a 50% performance improvement, so that's still very good. I've never used the PiDNG compression modes, so can't really tell you anything about it, and our users have never asked! I also put together an example showing what I think is probably the most direct way to save DNG files on the Pi, if users want the extra performance or features. Perhaps you could let me know if I've done anything obviously wrong there. I'm happy to host an example like this, or for you to do it (instead or as well) if that were useful. I probably can't integrate muimg directly into Picamera2 because of the license (interesting as that might be). I think users will have to download and install it for themselves, being fully aware what the licensing requirements are. Anyway, maybe let me know if you're happy simply for me to host that example in our repo like this, or would like to do anything different. Thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I think it's essential for any photo device to offer proper raw/dng encoding. In Picamera2, DNG encoding is done by a third party PiDNG library. This has the merit of existing, but it's far from optimal, as the encoding is extremely slow, probably due to the use of Python, despite good use of numpy.
I think the Raspberry Foundation should take on the task of making this encoding more efficient.
I'd also like to point out that when using DNG encoding, do not use CSI2P compressed formats, as decompression before encoding is catastrophically slow!
Regards
Beta Was this translation helpful? Give feedback.
All reactions