attah | OpenCV namedWindow looks a bit wonky on SFOS, but it does work! | 13:15 |
---|---|---|
mal | attah: can you show how it looks? | 14:44 |
attah | mal: sec | 14:45 |
attah | mal: https://meme.attah.net/opencv | 14:50 |
* attah should really make uploading images faster | 14:51 | |
direc85[m] | Looks cool! | 14:51 |
*** fifr is now known as Guest9754 | 16:32 | |
*** fifr` is now known as fifr | 16:32 | |
mal | nephros: hi, are you around? | 17:43 |
attah | Any ideas what is a performant Qt widget to dump pixel data to? Preferrably something that can do BGR and allows updates from out-of-thread | 18:19 |
attah | QQuickPaintedItem whioch i tried now seems a bit too indirect | 18:20 |
mal | would canvas work? | 18:21 |
attah | Maybe... i'll read up a bit and see | 18:22 |
attah | How is that used though? "qt canvas c++" gives only crap results | 18:23 |
mal | hmm, maybe I remember incorrectly then | 18:24 |
attah | OpenCV has some Qt bindings obviously too... but once again my google-fu fails | 18:25 |
mal | attah: in what format is the data? | 18:25 |
attah | I think contiguous 3-byte BGR | 18:26 |
attah | But they don't exactly feel like being clear on that in the docs | 18:26 |
mal | attah: is creating QImage or QPixmap from the data slow? | 18:36 |
attah | Well, some combination of the way i'm doing it, the resizing, and getting it on the screen is | 18:37 |
attah | ...and it's the wrong way around | 18:37 |
Nico | If you want to dump pixels, wouldn't you use an Image instead of a QQuickPaintedItem? Or a QQuickItem with a custom texture? | 18:38 |
attah | I have absolutely no idea | 18:38 |
Nico | At least that is what I use :D | 18:38 |
attah | I thought these painteresque things *should* be better than images | 18:39 |
attah | Since why else would they exist? | 18:39 |
attah | Also i am unsure about ownership of images | 18:40 |
Nico | QQuickPaintedItem first draws to an item using QPainter and then flips a texture in the scene graph | 18:41 |
attah | hoping to not have to put a lock around it | 18:41 |
Nico | If you already have pixels, putting them into an Image makes more sense | 18:41 |
Nico | Or a texture | 18:41 |
Nico | Since that will just be directly in the scene graph | 18:41 |
attah | But how is that safe to access from the main thread if i'm randomly updating it? | 18:42 |
Nico | It is probably not, but you can dump it to a different texture and then tell the scenegraph to swap the texture | 18:42 |
attah | I though that was more or less what these other things were for | 18:43 |
attah | though currently i'm sat with a QQuickPaintedItem *and* broken images | 18:43 |
Nico | No, read the QQuickPaintedItem documentation :p | 18:43 |
Nico | It just draws to a QImage and as such occurs overhead | 18:44 |
Nico | Do you want to draw pixel by pixel or just load an image? | 18:44 |
attah | I want to load images | 18:46 |
Nico | Then you will probably have better performance directly loading to a QImage or QSGTexture | 18:46 |
attah | Hmm | 18:49 |
Nico | And your format is QImage::Format_BGR888, isn't it? | 18:49 |
Nico | Well, sadly that is a Qt 5.14 feature :p | 18:49 |
attah | yes, that | 18:49 |
Nico | (RGB888 should work fine on sailfish) | 18:49 |
attah | just backwards | 18:50 |
mal | quite odd why they didn't have 888 in older versions | 18:50 |
Nico | Probably nobody needed it | 18:50 |
attah | Thing is BGR is old, not some new fancy stuff | 18:50 |
Nico | Yeah, but QImage is not a texture, and afaik BGR was mostly used for textures | 18:51 |
attah | I tried images, but i can't just put them out there. AFAICT providers can't push updates, and to show images i need a custom object, which is a QQuickPaintedItem in my case | 18:51 |
attah | It is beyond silly that there is no builtin for that | 18:52 |
Nico | Use a QQUickItem like this: https://github.com/Nheko-Reborn/nheko/blob/224d845af370ac8d40bc085b7bc3d75ea5a05a3b/src/ui/MxcAnimatedImage.cpp#L173 | 18:52 |
attah | Hmm, that looks like tomorrow-levels of complex | 18:54 |
Nico | Like it is pretty much fast enough for me to render real time: https://nheko.im/deepbluev7/harbour-ohboy/-/blob/master/src/GameBoy.cpp?ref_type=heads#L272 | 18:54 |
attah | I just need 50kpixels 25FPS... so anything that isn't stupid should do it | 18:55 |
Nico | Yeah, just using an image should work fine for that | 18:56 |
attah | But in order to actually put it out there i need some go-between... so why can't i use that directly? aka, how is that better? | 18:57 |
Nico | (In my case I draw to the image pixel by pixel) | 18:57 |
attah | I had to resort to this: https://github.com/attah/harbour-seaprint/blob/master/src/imageitem.h | 18:58 |
Nico | You mean why you can't just put the image directly to the screen? Because it is not a GPU texture | 18:58 |
attah | No; i mean why doesn't qml let me just put an image somewhere? | 18:58 |
Nico | In your imageitem, you are actually drawing to another image, which then gets converted to a texture and uploaded | 18:59 |
attah | Also... if only i had something coded in a texture-friendly way already | 18:59 |
Nico | Well, the efficent way to put an image to the scene graph is a QSGImageNode | 19:01 |
Nico | But you need to wire it up to an item yourself, since the logic to push the new image is usually the interesting one | 19:01 |
Nico | And depends on the item type | 19:01 |
Nico | Same with the resizing logic | 19:01 |
attah | And i just remembered why that ImageItem didn't work straight off... if i let QML instantiate it; i can't get to it from C++ | 19:02 |
Nico | But you are instantiating C++ code, so you can run code there to hook it up | 19:03 |
attah | Well, that sounds like forcing me to push resizing to opencv, which is pretty much a feature | 19:03 |
attah | An then i'm back to doing it inside the ImageItem where i started | 19:03 |
Nico | Or you expose a function, that creates the item on demand and then use that function in qml | 19:03 |
Nico | The problem with your ImageItem is mostly, that you are copying the image 3 times | 19:03 |
Nico | Which you should be able to reduce at least to 2 but possibly even to 1 | 19:04 |
Nico | Alternatively, if you already have a texture, you can reuse that | 19:05 |
Nico | But your image is pretty small, so you can probably just copy it :D | 19:05 |
attah | Some combination of the double resizes, x number of copies and failing updates made it really choppy still :/ | 19:06 |
Nico | And if you have a texture, you can just let the GPU scale it | 19:06 |
Nico | Since it needs to sample the image anyway | 19:07 |
*** Sellerie4 is now known as Sellerie | 20:29 | |
*** Mikaela is now known as Guest9792 | 23:36 |
Generated by irclog2html.py 2.17.1 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!