Saturday, 2023-12-09

attahOpenCV namedWindow looks a bit wonky on SFOS, but it does work!13:15
malattah: can you show how it looks?14:44
attahmal: sec14:45
attahmal: https://meme.attah.net/opencv14:50
* attah should really make uploading images faster14:51
direc85[m]Looks cool!14:51
*** fifr is now known as Guest975416:32
*** fifr` is now known as fifr16:32
malnephros: hi, are you around?17:43
attahAny ideas what is a performant Qt widget to dump pixel data to? Preferrably something that can do BGR and allows updates from out-of-thread18:19
attahQQuickPaintedItem whioch i tried now seems a bit too indirect18:20
malwould canvas work?18:21
attahMaybe... i'll read up a bit and see18:22
attahHow is that used though? "qt canvas c++" gives only crap results18:23
malhmm, maybe I remember incorrectly then18:24
attahOpenCV has some Qt bindings obviously too... but once again my google-fu fails18:25
malattah: in what format is the data?18:25
attahI think contiguous 3-byte BGR18:26
attahBut they don't exactly feel like being clear on that in the docs18:26
malattah: is creating QImage or QPixmap from the data slow?18:36
attahWell, some combination of the way i'm doing it, the resizing, and getting it on the screen is18:37
attah...and it's the wrong way around18:37
NicoIf you want to dump pixels, wouldn't you use an Image instead of a QQuickPaintedItem? Or a QQuickItem with a custom texture?18:38
attahI have absolutely no idea18:38
NicoAt least that is what I use :D18:38
attahI thought these painteresque things *should* be better than images18:39
attahSince why else would they exist?18:39
attahAlso i am unsure about ownership of images18:40
NicoQQuickPaintedItem first draws to an item using QPainter and then flips a texture in the scene graph18:41
attahhoping to not have to put a lock around it18:41
NicoIf you already have pixels, putting them into an Image makes more sense18:41
NicoOr a texture18:41
NicoSince that will just be directly in the scene graph18:41
attahBut how is that safe to access from the main thread if i'm randomly updating it?18:42
NicoIt is probably not, but you can dump it to a different texture and then tell the scenegraph to swap the texture18:42
attahI though that was more or less what these other things were for18:43
attahthough currently i'm sat with a QQuickPaintedItem *and* broken images18:43
NicoNo, read the QQuickPaintedItem documentation :p18:43
NicoIt just draws to a QImage and as such occurs overhead18:44
NicoDo you want to draw pixel by pixel or just load an image?18:44
attahI want to load images18:46
NicoThen you will probably have better performance directly loading to a QImage or QSGTexture18:46
attahHmm18:49
NicoAnd your format is QImage::Format_BGR888, isn't it?18:49
NicoWell, sadly that is a Qt 5.14 feature :p18:49
attahyes, that18:49
Nico(RGB888 should work fine on sailfish)18:49
attahjust backwards18:50
malquite odd why they didn't have 888 in older versions18:50
NicoProbably nobody needed it18:50
attahThing is BGR is old, not some new fancy stuff18:50
NicoYeah, but QImage is not a texture, and afaik BGR was mostly used for textures18:51
attahI 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 case18:51
attahIt is beyond silly that there is no builtin for that18:52
NicoUse a QQUickItem like this: https://github.com/Nheko-Reborn/nheko/blob/224d845af370ac8d40bc085b7bc3d75ea5a05a3b/src/ui/MxcAnimatedImage.cpp#L17318:52
attahHmm, that looks like tomorrow-levels of complex18:54
NicoLike 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#L27218:54
attahI just need 50kpixels 25FPS... so anything that isn't stupid should do it18:55
NicoYeah, just using an image should work fine for that18:56
attahBut 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
attahI had to resort to this: https://github.com/attah/harbour-seaprint/blob/master/src/imageitem.h18:58
NicoYou mean why you can't just put the image directly to the screen? Because it is not a GPU texture18:58
attahNo; i mean why doesn't qml let me just put an image somewhere?18:58
NicoIn your imageitem, you are actually drawing to another image, which then gets converted to a texture and uploaded18:59
attahAlso... if only i had something coded in a texture-friendly way already18:59
NicoWell, the efficent way to put an image to the scene graph is a QSGImageNode19:01
NicoBut you need to wire it up to an item yourself, since the logic to push the new image is usually the interesting one19:01
NicoAnd depends on the item type19:01
NicoSame with the resizing logic19:01
attahAnd 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
NicoBut you are instantiating C++ code, so you can run code there to hook it up19:03
attahWell, that sounds like forcing me to push resizing to opencv, which is pretty much a feature19:03
attahAn then i'm back to doing it inside the ImageItem where i started19:03
NicoOr you expose a function, that creates the item on demand and then use that function in qml19:03
NicoThe problem with your ImageItem is mostly, that you are copying the image 3 times19:03
NicoWhich you should be able to reduce at least to 2 but possibly even to 119:04
NicoAlternatively, if you already have a texture, you can reuse that19:05
NicoBut your image is pretty small, so you can probably just copy it :D19:05
attahSome combination of the double resizes, x number of copies and failing updates made it really choppy still :/19:06
NicoAnd if you have a texture, you can just let the GPU scale it19:06
NicoSince it needs to sample the image anyway19:07
*** Sellerie4 is now known as Sellerie20:29
*** Mikaela is now known as Guest979223:36

Generated by irclog2html.py 2.17.1 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!