Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Call/delegate to Android Camera-app that returns image in Qt?
Forum Updated to NodeBB v4.3 + New Features

Call/delegate to Android Camera-app that returns image in Qt?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 4 Posters 2.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pga4711
    wrote on last edited by
    #1

    Hello, I am trying to develop an Qt app in Qt Widget that opens the stock/OEM Android Camera App so the user can take a photo and the app gets the returned photo, a QImage for example. (The image will be used in some kind of PDF report with text ect, but that might be another story)

    I tried to create an app with the QCamera, QCameraImageCapture, QCameraViewfinder, QCameraInfo ect . But i realize that it might be a lot of work if i would implement settings like focus, exposure, zoom ect. It would be better to delegate to the existing "Android Camera"-functionality.

    In native Android Studio you might use MediaStore.ACTION_IMAGE_CAPTURE https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE
    But i don't know what to use in Qt.

    Someone who know how to this in Qt?

    1 Reply Last reply
    0
    • Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @pga4711 said in Call/delegate to Android Camera-app that returns image in Qt?:

      I am trying to develop an Qt app in Qt Widget

      Is using Qt Widget a strict requirement? If not, you may want to take a look at this QML Camera example.

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • SR__S Offline
        SR__S Offline
        SR__
        wrote on last edited by
        #3

        In Qt for Android, you can :

        • add AndroidExtras to benefit from an API in order to start an Activity and receive the result in a C++ callback.
        • use JNI to do the same, in order to add specific stuff that would be available in Java only (as using a SDK available in Java and not C++).
        1 Reply Last reply
        2
        • P Offline
          P Offline
          pga4711
          wrote on last edited by pga4711
          #4

          @Pablo-J.-Rogina said in Call/delegate to Android Camera-app that returns image in Qt?:

          @pga4711 said in Call/delegate to Android Camera-app that returns image in Qt?:

          I am trying to develop an Qt app in Qt Widget

          Is using Qt Widget a strict requirement? If not, you may want to take a look at this QML Camera example and QML Camera Example. The camera "realtime image flow" seems to work in the QML example but not in the Qt Widget Camera Example

          As it looks now, it would be good if i try to do things with Qt Widget, because my fellows around me understands that. But if things don't work so well in Qt Widget i might have a look at QML. There might be a 2-3 days learning curve for introduction in QML?

          I hade a look at both Camera Example and QML Camera Example. The problem is that there is no “real time camera image flow” in the Qt Widget Camera Example. Someone who know why? It might be a known problem?

          Another thing: What is QCameraViewfinder ? It feel very abstract. Is it a view where we can put images in or what? :>

          @SR__ said in Call/delegate to Android Camera-app that returns image in Qt?:

          In Qt for Android, you can :

          • add AndroidExtras to benefit from an API in order to start an Activity and receive the result in a C++ callback.
          • use JNI to do the same, in order to add specific stuff that would be available in Java only (as using a SDK available in Java and not C++).

          I think your recommendation is very good.

          I have tried some small steps with this small scale example about choosing picture from Android Gallery. There were/are some issues. I changed the “Minimum required SDK” to “API 19” and “Target SDK” to ”API 26”, so now things will compile and make.

          And now i can run the example. I feel very dizzy about these lines for example:
          selectedFileName = "#";
          QAndroidJniObject::callStaticMethod<void>("com/amin/QtAndroidGallery/QtAndroidGallery",
          "openAnImage",
          "()V");
          while(selectedFileName == "#")
          qApp->processEvents();

          The selectedFileName always contains the empty string :(

          Someone who have ideas how to proceed next? :) For example, what is wrong with the Qt Widget Camera Example, and how to get directory path from openAnImage-method ...

          1 Reply Last reply
          0
          • R Offline
            R Offline
            refaQtor
            wrote on last edited by
            #5

            While it has gotten a lot better to use JNI methods with Android, I still avoid them whenever possible. Especially, when I wish to support iOS, also; and Windows/Mac tablets...all with identical code, only minor tweaks for install.
            I've found the Qt camera (Widgets or QML) to work well - even realtime viewing, just re-using big chunks of the example code. The zoom/white balance/focus controls automatically show, or not, as the actual device is able to support them.
            The secret that made it all work much easier for me, was to avoid the un-necessary extra signal/slot stuff for a simple picture....

            mycamerainstance.captureToLocation(myValidLocalFilename);
            

            I'd suggest trying skipping the platform camera, and trying the Qt Camera again, using the simpler captureToLocation call. I've found this way simplest.
            Good luck!

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved