[Example] Camera Service (high framerate and fast drawing)

Discussion in '3DS - Homebrew Development and Emulators' started by Nba_Yoh, Nov 12, 2015.

  1. Nba_Yoh
    OP

    Nba_Yoh GBAtemp Fan

    Member
    310
    288
    Jan 5, 2015
    France
    Hello everyone.

    I tested a few tricks with the camera last week. I was really disappointed to not be able to run the camera at the maximum frame rate without having some timeout results. I investigated the thing and I got the thing to work fine. Unfortunately, drawing the image was taking a too long time and the loop was only iterating 20 times per second. I continued my research and tests and I finally got it to work. I decided to share it so.

    The code is available on GitHub : https://github.com/MrNbaYoh/3DSCameraExample

    I will surely make some improvements and explain how the thing is working because the documentation concerning the Camera and Y2R services are really lean on 3dbrew.

    Maybe a video would be nice ?
     
    ihaveamac, kiwiis, I pwned U! and 3 others like this.


  2. Goombi

    Goombi Meme crypto = my crypto

    Member
    143
    53
    Jun 1, 2014
    France
    RnVja1lvdU15RHVkZQ
    Tested it (N3DS 10.3, *hax 2.5 from 11/9, IronHax,), worked perfectly! That smooth 60fps is great, good job!
    Combined to the "Home = Screenshot" function we now have a rudimentary but functionnal HB camera app.
     
  3. Nba_Yoh
    OP

    Nba_Yoh GBAtemp Fan

    Member
    310
    288
    Jan 5, 2015
    France
    The loop is iterating 60 times per second but the camera max frame rate is 30.

    Implementing a way to save the current frame from the camera is not hard and should be more efficient than the "home button screenshot".
    I will try to document and explain all of the thing, and improve it to make the camera easier to use.
     
  4. Giodude

    Giodude Ruler of Italy

    Member
    GBAtemp Patron
    Giodude is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    3,613
    1,009
    May 17, 2015
    United States
    New York
    compiled .3dsx..............................................................? Pls............................................
     
  5. Nba_Yoh
    OP

    Nba_Yoh GBAtemp Fan

    Member
    310
    288
    Jan 5, 2015
    France
    Done.
     
  6. Giodude

    Giodude Ruler of Italy

    Member
    GBAtemp Patron
    Giodude is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    3,613
    1,009
    May 17, 2015
    United States
    New York
    is there a link?
     
  7. lolzvid

    lolzvid GBAtemp Regular

    Member
    148
    115
    Dec 26, 2014
    Brazil
    There's the Github link at OP's post with the .3dsx and .smdh files.
     
  8. MasterLel

    MasterLel You have an error in your SQL syntax;

    Member
    1,240
    449
    Mar 14, 2015
    France
  9. Giodude

    Giodude Ruler of Italy

    Member
    GBAtemp Patron
    Giodude is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    3,613
    1,009
    May 17, 2015
    United States
    New York
    got it, thanks, lemme give it a test
     
  10. Urbanshadow

    Urbanshadow GBAtemp Maniac

    Member
    1,289
    469
    Oct 16, 2015
    Oh, this is cool! Do you get both cameras with the camera service? Can we develop our AR thingies with this?
     
  11. Giodude

    Giodude Ruler of Italy

    Member
    GBAtemp Patron
    Giodude is a Patron of GBAtemp and is helping us stay independent!

    Our Patreon
    3,613
    1,009
    May 17, 2015
    United States
    New York
    wow. Works perfectly.
     
  12. Nba_Yoh
    OP

    Nba_Yoh GBAtemp Fan

    Member
    310
    288
    Jan 5, 2015
    France
    Yep, you may use both cameras but it will maybe require some supplementary drawings and then cause a TPS decrease.
     
  13. lolzvid

    lolzvid GBAtemp Regular

    Member
    148
    115
    Dec 26, 2014
    Brazil
    I've tested it on my O3DS 9.2.0-20 (homemenuHax and ninjhax 2.5) and it crashed every single time (needs to power off the system to exit the app)...

    :(
     
  14. Urbanshadow

    Urbanshadow GBAtemp Maniac

    Member
    1,289
    469
    Oct 16, 2015
    I think I can cope with that. Roughly 30 fps would be fine. I'm more worried about the picture treatment (otsu, I believe. Ransac would be best but overkill) taking too long to process rather than some drawings.
     
  15. Blundermann

    Blundermann GBAtemp Regular

    Member
    173
    123
    Oct 15, 2013
    United States
    I'm on an O3DS 9.9 and it doesn't work for me either. Results in a crash.
     
  16. Nba_Yoh
    OP

    Nba_Yoh GBAtemp Fan

    Member
    310
    288
    Jan 5, 2015
    France
    Did you download the xml file too ?
     
  17. lolzvid

    lolzvid GBAtemp Regular

    Member
    148
    115
    Dec 26, 2014
    Brazil
    No, silly me :ha:

    Now it's working flawlessly, thanks!
     
    Blundermann and Nba_Yoh like this.
  18. Blundermann

    Blundermann GBAtemp Regular

    Member
    173
    123
    Oct 15, 2013
    United States
    I did forget it, and it starts up fine now!
    However, I've run into another issue.

    It makes a noise, renders about five or so frames, then the top screen freezes, and the bottom screen continues to draw 59-60.
    What do I do?
     
  19. Nba_Yoh
    OP

    Nba_Yoh GBAtemp Fan

    Member
    310
    288
    Jan 5, 2015
    France
    Looks like a timeout problem, interesting I will test with my O3DS.
     
  20. MyLegGuy

    MyLegGuy Moron

    Member
    467
    259
    Nov 26, 2014
    United States
    Woah! This is cool!

    I don't even remember the 3ds's camera in the camera app being this smooth!
    (But I haven't used that in ages.)

    It's great how it doesn't take forever to load, and you can take pictures without the world's loudest sound.