Homebrew [Release] dsi-camera, a PoC / example homebrew using the DSi's cameras

Pk11

A catgirl with a DSi
OP
Member
Joined
Jun 26, 2019
Messages
752
Trophies
1
Age
20
Location
米国
Website
pk11.us
XP
2,585
Country
United States
I've been wanting to make a homebrew app that can use the DSi's cameras for quite a while, but was stuck since whatever I did it just wouldn't actually get an image, but thanks to @StapleButter's research for melonDSi they found the problem and I was able to fix my app too! So here's the first (public) homebrew app that can use the DSi's cameras afaik!

Its not really anything too exciting as all it can do is show both cameras and take a picture as a BMP, but the code is here and working with libnds/devkitARM in C/C++ so hopefully that's helpful if anyone else wants to use the cameras in a homebrew app. I'll probably try add QR code support to pkmn-chest and maybe work on a fancier camera app too soon, but this one is just a simple example.

:download: Download on GitHub if you want to try it, the source code is there too

Example photo: (converted to png)
photo.png

Update See below for updated feature list and example image
 
Last edited by Pk11,
v1.1.0

Pk11

A catgirl with a DSi
OP
Member
Joined
Jun 26, 2019
Messages
752
Trophies
1
Age
20
Location
米国
Website
pk11.us
XP
2,585
Country
United States

Version 1.1.0 - 640×480

What's new?​

  • Photos are now saved at 640×480! (Thanks to @Arisotura once again for pointing out the obvious fix lol)
  • Photos are now saved as 24-bit PNGs instead of 15-bit BMPs, as YUV mode is now used for higher quality
  • Photos are new saved to sd:/DCIM/100DSI00/IMG_####.PNG, allowing for multiple images to be taken
  • Changed the source to be 100% C, since it was already effectively C but using C++ files

:download: As usual, download is on GitHub and Universal-DB

New example photo:
example.png


Edit: Hotfixed the release to simply change the save location to 100DSI00, didn't notice that DCF folders are supposed to be exactly 8 characters long.



Finally got 640×480 mode working! The fix was actually super simple lol, but last time I tried I couldn't quite find what was wrong. This example is now a bit more reasonable and able to take pictures more or less on par with the official app, using 640×480 resolution and YUV mode directly to RGB8 for better quality. I'd still like to look into the other settings and maybe add some way to give the user finer control over the camera, but for the moment it's still just as basic as always but a little more useful.

PS. The non-floating point YUV to RGB math has to be some of the most cursed math I've seen lol
94dec249fc676c933ec41e5c5ced22e010344a8d

C:
#define YUV_TO_R(Y, Cr) clamp(Y + Cr + (Cr >> 2) + (Cr >> 3) + (Cr >> 5), 0, 0xFF)
#define YUV_TO_G(Y, Cb, Cr) clamp(Y - ((Cb >> 2) + (Cb >> 4) + (Cb >> 5)) - ((Cr >> 1) + (Cr >> 3) + (Cr >> 4) + (Cr >> 5)), 0, 0xFF)
#define YUV_TO_B(Y, Cb) clamp(Y + Cb + (Cb >> 1) + (Cb >> 2) + (Cb >> 6), 0, 0xFF)
YUV to RGB is already really weird but I noticed Wikipedia had an integer version of it and since the DS doesn't have hardware floating point I did a comparison and it was like 8x faster or something like that so cursed math it is.
 
Last edited by Pk11,

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,913
Trophies
1
XP
2,225
Country
Chile

Version 1.1.0 - 640×480

What's new?​

  • Photos are now saved at 640×480! (Thanks to @Arisotura once again for pointing out the obvious fix lol)
  • Photos are now saved as 24-bit PNGs instead of 15-bit BMPs, as YUV mode is now used for higher quality
  • Photos are new saved to sd:/DCIM/100DSITEST/IMG_####.PNG, allowing for multiple images to be taken
  • Changed the source to be 100% C, since it was already effectively C but using C++ files

:download: As usual, download is on GitHub and Universal-DB

New example photo:
example.png




Finally got 640×480 mode working! The fix was actually super simple lol, but last time I tried I couldn't quite find what was wrong. This example is now a bit more reasonable and able to take pictures more or less on par with the official app, using 640×480 resolution and YUV mode directly to RGB8 for better quality. I'd still like to look into the other settings and maybe add some way to give the user finer control over the camera, but for the moment it's still just as basic as always but a little more useful.

PS. The non-floating point YUV to RGB math has to be some of the most cursed math I've seen lol
94dec249fc676c933ec41e5c5ced22e010344a8d

C:
#define YUV_TO_R(Y, Cr) clamp(Y + Cr + (Cr >> 2) + (Cr >> 3) + (Cr >> 5), 0, 0xFF)
#define YUV_TO_G(Y, Cb, Cr) clamp(Y - ((Cb >> 2) + (Cb >> 4) + (Cb >> 5)) - ((Cr >> 1) + (Cr >> 3) + (Cr >> 4) + (Cr >> 5)), 0, 0xFF)
#define YUV_TO_B(Y, Cb) clamp(Y + Cb + (Cb >> 1) + (Cb >> 2) + (Cb >> 6), 0, 0xFF)
YUV to RGB is already really weird but I noticed Wikipedia had an integer version of it and since the DS doesn't have hardware floating point I did a comparison and it was like 8x faster or something like that so cursed math it is.
excellent
 
General chit-chat
Help Users
  • No one is chatting at the moment.
    KenniesNewName @ KenniesNewName: https://youtu.be/Ueu-y2rE16k