How can i set rotation of camera capture request? - android

I'm using ndk to create application that captures through camera and displays the images. I succeed to capture and display images but the rotation of images is not normal. So, i tried to change the rotation of images by using ACaptureRequest_setEntry_u8 function. But it returns this error message in logcat(E/ACameraMetadata: Error: tag 917518 is not writable!). I tried to check whether ACAMERA_SENSOR_ORIENTATION is included in ACameraMetadata and it is.
Below is the code. I used two days to correct this problem. Please help me.
ACameraDevice_createCaptureRequest(mainCameraDevice, TEMPLATE_STILL_CAPTURE,
&mainCaptureRequest);
uint8_t degree = 90;
ACaptureRequest_setEntry_u8(mainCaptureRequest, ACAMERA_SENSOR_ORIENTATION, 1, &degree);
And i'm using ACameraCaptureSession_setRepeatingRequest to capture sequentially.

I'm not using NDK to take a picture but I've done the following to correctly rotate the output image:
https://stackoverflow.com/a/51892093/10159898
Given code are both in Kotlin and Java.
Hope It can help you

Related

How get Matrix4x4 from Pose from ArCamera in ARCore NDK?

On Google Samples I can get samples about getting the Matrix from a Pose generated by an ArAnchor or from a ArPlane. But when I'm trying to get from ArCamera is not working, my result is an Identity Matrix.
Small part from my code:
ScopedArPose scopedArPose(ar_session_);
ArCamera_getPose(ar_session_, ar_camera, scopedArPose.GetArPose());
std::array<float, 16> out_matrix_col_major_4x4;
ArPose_getMatrix(ar_session_, scopedArPose.GetArPose(), out_matrix_col_major_4x4.data());
What is working:
ArSession is working, ArFrame is ok, I'm able to get ArCamera, ArCameraIntrinsicsis ok, ArImage is ok, AImage is ok.
Format and NumberOfPlanes from Image are ok.
ScopedArPose class is equal from google samples. array<float, 16> works fine, tested in google samples.
What is missing?
To solve this problem it needed to check the camera state before.
ArTrackingState camera_tracking_state;
ArCamera_getTrackingState(ar_session_, ar_camera, &camera_tracking_state);
// If the camera isn't tracking don't bother to go forward
if (camera_tracking_state != AR_TRACKING_STATE_TRACKING) {
LOGI("ARCoreOdometry: Camera Not Tracking");
return;
}

Are Somebody knows how to rotate liveviewOrientation in Sony Camera remote API

I'm using the Sony Camera API for taking a picture remotely, but when I rotate the camera streaming image is still vertical. API ver. is 2.40. I checked the Reference of API but there is nothing about orientation of live view
Look to api getevent (pooling or callback) , you will see a liveviewOrientation value in the result.
{
"type":"liveviewOrientation",
"liveviewOrientation":"90"
}
Then you have to rotate your output stream.
It's device dependant
Rotate:
Read the stream, look for Common Header to decode "Packet",then extract JPEG image from one "Packet",decode it.
Rotate the image according to liveviewOrientation, then show it to your display.

Take photo and record video of real-time face detection preview

I have used JavaCv (and opencv too) to implement live face detection preview on Android. I work ok. Now I want to take a picture or record a video from live preview which have face detection (I mean when I take a picture, this picture will have a person and a rectangle around his/her face). I have researched a lot but get no result. Can anyone help me please !!!
What you're looking for is the imwrite() method.
Since your question isn't clear on the use-case, I'll give a generic algorithm, as shown:
imwrite writes a specified Mat object to a file and it accepts 2 arguments - fileName and Mat object, for example - imwrite('output.jpg',img);
Here's the logic you can follow:
Receive input frame (Mat input from video and run face detection using your existing method.
Draw a rectangle on an output image (Mat output).
Use imwrite as - imwrite('face.jpg',output)
In case you want to record all the frames with a face in them, replace 'face.jpg' with a string variable that is updated with each loop iteration and run imwrite in a loop
If you wish to record a video. Have a look at VideoWriter() class

capture a live image from camera using python, uiautomator

My application requires to capture a picture from the Android Camera.
from you Automatorviewer, the click softbutton of the camera is not being indentified, it is only displaying the View and the relative layout.
Please can someone help with this.
Thank you guys, I found the answer using the below
rowcount = d(textStartsWith="XXX").count
print rowcount
This returns the exact number of rows starting with same letters/characters

Android Camera.takePicture - Possible to disable shutter sound and preview surface?

I am working on an app that will allow a user to take quick click and forget snapshots. Most of the app is done except for the camera working that way I would like. Right now I have the camera working but I can't seem to find a way to disable the shutter sound and I cant find a way to disable displaying the preview. I was able to cover the preview up with a control but I would rather just not have it displayed if possible.
To sum things up, these are the items that I would like to disable while utilizing the built in Camera controls.
Shutter sound
Camera screen display
Image preview onPictureTaken
Does anyone know of a resource that could point me in the right direction, I would greatly appreciate it. I have been following CommonsWare's example from this sample fairly closely.
Thank you.
This is actually a property in the build.prop of a phone. I'm unsure if its possible to change this. Unless you completely override it and use your own camera code. Using what you can that is available in the SDK.
Take a look at this:
CameraService.cpp
. . .
CameraService::Client::Client(const sp<CameraService>& cameraService,
const sp<ICameraClient>& cameraClient,
const sp<CameraHardwareInterface>& hardware,
int cameraId, int cameraFacing, int clientPid) {
mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
mOrientation = getOrientation(0, mCameraFacing == CAMERA_FACING_FRONT);
mOrientationChanged = false;
cameraService->setCameraBusy(cameraId);
cameraService->loadSound();
LOG1("Client::Client X (pid %d)", callingPid)
}
void CameraService::loadSound() {
Mutex::Autolock lock(mSoundLock);
LOG1("CameraService::loadSound ref=%d", mSoundRef);
if (mSoundRef++) return;
mSoundPlayer[SOUND_SHUTTER] = newMediaPlayer("/system/media/audio/ui/camera_click.ogg");
mSoundPlayer[SOUND_RECORDING] = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg");
}
As can be noted, the click sound is started without your interaction.
This is the service used in the Gingerbread Source code.
The reason they DON'T allow this is because it is illegal is some countries. Only way to achieve what you want is to have a custom ROM.
Update
If what being said here: http://androidforums.com/t-mobile-g1/6371-camera-shutter-sound-effect-off.html
still applies, then you could write a timer that turns off the sound (Silent Mode) for a couple of seconds and then turn it back on each time you take a picture.
You may use the data from the preview callback using a function to save it at a picture on some type of trigger such as a button, using onclick listener. you could compress the image to jpeg or png. In this way, there no shutterCallback to be implemented. and therefore you can play any sound you want or none when taking a picture.
You can effectively hide the preview surface by giving it dimensions of 1p in the xml file (I found an example the said 0p but for some reason that was giving me errors).
It may be illegal to have a silent shutter in some places, but it doesn't appear that the US is such a place, as my HTC One gives me an option to silence it, and in fact, since Android 4.2 you can do this:
Camera.CameraInfo info=new Camera.CameraInfo();
if (info.canDisableShutterSound) {
camera.enableShutterSound(false);
}

Categories

Resources