How to display image on Android device using QT? - android

I'm trying to create an Android application using QT where I load image from the device and display it on the application.
I can create an application and load it to an Android device, and I can also successfully import OpenCV.
I'm having problem loading image file using:
QFile::exists("PATH_TO_FILE");
QImage image("PATH_TO_FILE");
QFile::exists says that the file I'm trying to load exists. However, when I try to load the image, my image is null.
I've tried loading an image from both internal and external memory with the following permission added to my AndroidManifest.xml: android.permission.READ_EXTERNAL_STORAGE.
I want to load image from the device camera and display it on the widget. I can compile the application with OpenCV. However, when I tried to get image by:
VideoCapture vid;
vid.open(0);
Mat img;
vid >> img;
I get image of size 0. I did added permission android.permission.CAMERA to my AndroidManifest.xml.
Can someone please help me out? I'm not sure what I'm missing and why I'm getting null images from both files and cameras.
Any help would be appreciated
Sincerely,
Steve

Related

Cordova Camera Plugin: Not allowed to load local resource (content://)

I have a Cordova app. In some part of the app, I let the user choose a photo from the gallery or take one with the camera. For this purpose, I’m using cordova-plugin-camera.
The problem is when the user takes a photo with the camera, the preview is fine, but when they choose it from the gallery, the preview of the photo is broken.
This is the error I get for the broken preview:
Not allowed to load local resource: content://com.android.providers.media.documents/document/image%3A6717.
I'm using navigator.camera.getPicture function with destinationType: Camera.DestinationType.NATIVE_URL.
This happens on Android devices. Do you have any idea what causes this?
By the way, I have already added <access origin="content:///*" /> to the config.xml file, but it's not working.
The solution is to convert content URI to the native path using cordova-plugin-filepath:
https://stackoverflow.com/a/33127554/3752067

capture camera image but not save a file

Is it possible to capture a camera image and use it in my code, but not have the image saved on the device? I need the image for sending to an API, but I have no need for the user to have the file afterwards. Can this be done?
This is not a good idea, as there is too much overhead when handling the full size image in RAM.
I would personally just create a scaled down preview to put in UI(if needed), then upload original(saved on SD) image and delete afterwards.
Some devices will force the images into the gallery.
This will help you with said problem
Here is my edited answer in regard to how i would do it.
Save image to disk and ensure it is encoded correctly for the API you are using.
Start upload service when network connection is available (if necessary).
Either delete image from service or schedule an Alarm to start service and deal with it later
if u r using native camera activity
capture the image on file
get the bitmap of the image from the file
delete the file
(u can save the image in hidden directory {{its name should start with dot .hidden_dir/myimg.jpg }} )

Android Image viewer app test

I am trying to follow the link below for the code for a Image viewing app in android.
android image "viewer" app
But I am getting an error with the r.raw.image1. (also on raw.image2 and image3). I have saved the images in the asset folder. Error says raw cannot be resolved or is not a field. I have checked various documentations for this but am unable to understand what i am doing wrong. The code is exactly the same as in the above link.
Try to save your image into res/raw folder.

How to avoid saving picture at gallery or delete it automatically in Android?

The device is Samsung Galaxy III. I developed an APP to run the camera activity and capture an image. After analyzing the image, I print out some text information. Right now every captured image is saved at gallery. I don't need the image to be saved in gallery or SD card. I think either of the following two solutions will work for me, but I don't know how to program it:
avoid saving pictures to gallery.
delete the picture somewhere in the APP.
Any comments are appreciated.
Read Android Camera tutorial.
...
Storage - Are the images or videos your application generates intended to be only visible to your application or shared so that other applications such as Gallery or other media and social apps can use them? Do you want the pictures and videos to be available even if your application is uninstalled? Check out the Saving Media Files section to see how to implement these options.
or see this one: How to save image captured with camera in specific folder.
In the Camera intent when starting, add this:
intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(getTempFile(context)));
I solved my problem with following two steps:
as '#auselen' pointed, save all the images to a specific folder. How to save image captured with camera in specific folder.
delete all the images in that folder somewhere in the APP. How to Delete Image From SDCard in Android
use this for delete a pic
ImgPhoto1.setImageBitmap(null);

When I try to push a photo onto the android emulator, I am not able to see the photo in Albums

I am new to Android and now trying to retrieve contact photo (thumb nail) from a content provider and set it onto my app. But for that as i am running on an AVD, i pushed some .png photos onto my 2.2 version. Now i tried to create a contact with the photo, but the Gallery is showing "No Media Found", hence i am stuck here.
Please help me in getting the photo visible in gallery.
Note : I am aware of the following facts :
I have restarted my AVD to force the Media Scanner to do its initial mockups.
Also i have seen the .png file through the File Explorer View of Eclipse Framework.
But strangely, I am not able to pull the file off the phone.
I have taken help of the link get the path of a Gallery Folder in Android for understanding the general view on Media Scanner.
I believe this is because the application doesn't know if there are images inside /data.
Try to put your images in:
/mnt/sdcard/Pictures

Categories

Resources