How to get intrinsic and extrinsic parameter matrix of my camera using Google ARCore - android-camera

I want to use Google ARCore to get the extrinsic and intrinsic parameter matrix of my mobile phone. So far, I only see documentation about getting the intrinsic parameter matrix but I don't see anything about getting the extrinsic parameter matrix. Is it possible to do that with Google ARCore?

Thought I'd just update this with an answer I found a while ago:
Frame frame = arSceneView.getArFrame();
Camera camera = frame.getCamera();
CameraIntrinsics intrinsics = camera.getImageIntrinsics();
Camera coreCamera = frame.getCamera();
Pose camPose = coreCamera.getPose();

Related

Matlab Kinect Depth Imaging

I'm working with the kinect camera and trying to display real-life depth imaging using the ptCloud method combining the RGB and Depth Sensor. However just using the initial setup my image is disfigured missing pertinent information, is there anyway to improve this so that it captures more data. I have also attached an image of what i mean. Any help would be great thank you!
colorDevice = imaq.VideoDevice('kinect',1)
depthDevice = imaq.VideoDevice('kinect',2)
step(colorDevice);
step(depthDevice);
colorImage = step(colorDevice);`enter code here`
depthImage = step(depthDevice);
gridstep = 0.1;
ptCloud = pcfromkinect(depthDevice,depthImage,colorImage);
player = pcplayer(ptCloud.XLimits,ptCloud.YLimits,ptCloud.ZLimits,...
'VerticalAxis','y','VerticalAxisDir','down');
xlabel(player.Axes,'X (m)');
ylabel(player.Axes,'Y (m)');
zlabel(player.Axes,'Z (m)');
for i = 1:1000
colorImage = step(colorDevice);
depthImage = step(depthDevice);
ptCloud = pcfromkinect(depthDevice,depthImage,colorImage);
ptCloudOut = pcdenoise(ptCloud);
view(player,ptCloudOut);
end
release(colorDevice);
release(depthDevice);
From the looks of the image, you are trying to capture a cabinet with a TV screen in the middle. In cases like these, the TV screen actually absorbs the IR emitted from the sensor or reflects it at oblong angles/multiple reflections etc. Therefore Kinect is unable to capture the depth data. Furthermore, since when you want to display the RGB data on top of the point cloud, it tries to align the two and rejects any depth data that is not aligned with the RGB image pixels.
So in order to improve your depth data acquisition, you could either take care that there are no reflective surfaces like screen, mirrors etc in the scene. Also, try displaying the depth data without the RGB overlay, which will hopefully improve the point cloud shown.

Optical lense distance from an object

I am using a Raspberry PI camera and the problem in hand is how to find the best position for it in order to fully see an object.
The object looks like this:
Question is how to find the perfect position given that the camera is placed in the centre of the above image. Perfectly the camera will be able to catch the object only, as the idea is to get the camera as close as possible.
Take a picture with you camera, save it as a JPG, then open it in a viewer that allows you to inspect the EXIF header. If you are lucky you should see the focal length (in mm) and the sensor size. If the latter is missing, you can probably work it out from the sensor's spec sheet (see here to start). From the two quantities you can work out the angle of the field of view (HorizFOV = atan(0.5 * sensor_width / focal_length), VertFOV = atan(0.5 * sensor_height / focal_length). From these angles you can derive an approximate distance from your subject that will keep it fully in view.
Note that these are only approximations. Nonlinear lens distortion will produce a slightly larger effective FOV, especially near the corners.

Parallel camera planes rectification

I am doing an experiment in which I have multiple cameras targeted to capture scenes as they are capturing them from a 2D plane. But the problem is their orientation which may change because of some movement and my target is to rectify those orientations only not translation.
I am trying to approach this problem in two ways:
I am trying to estimate relative camera pose from MATLAB function and then transforming the second image using T i.e. KRK^-1.
Second I am trying to address this problem using regular camera rectification problem using estimateUncalibratedRectification. The function return two transformations, T1 and T2, which can be directly used to warp two images. Instead of applying transformation on image separately what I am doing is to only apply transformation on second image and the transformation matrix is T1^-1*T2. My assumptions is that in this way I will have camera orientation equals to 0.
I am verifying if the transformations are correct by observing the farthest feature point which must be near to each other.
What problems I am facing using the first approach is:
Not getting the farthest point to 0.
Please correct my approach.

Aligning VideoOverlayScreen with Mesh camera

How do you properly place the Video overlay on the back of a meshing camera, so that the mesh generated matches what's seen in the video?
(Using Unity 5.2.1f3)
I think there are two important parts needed in order to make sure the video overlay align with the mesh:
The render camera's projection matrix
You have to make sure the projection matrix of your render camera matches the projection matrix of the physical camera. That requires a customized projection matrix calculated based on Tango color camera's intrinsics value. Here is a snippet of sample code doing that (quoted from tango unity example). After the projection matrix is matched, the image you see will be aligned with the meshes.
Timestampe synchronization.
To be more precise on the rendering, you might want to do a synchronization between the point cloud, color camera, and the pose. To do that, you will need to query a pose based on color camera's update timestamp. Each time you received a point cloud, you need to transform the points to the color camera frame, because the point cloud is received in different timestamp. Then use the transformed point cloud to do the mesh reconstruction. Put it in a matrix equation:
P_color = inverse(ss_T_color) * ss_T_depth* P_depth

Is there any open source sdk like cam scanner in iphone sdk [duplicate]

I am stuck in my application feature. I want cropping feature similar to Cam Scanner Cropping.
The screens of CAM-SCANNER are:
I have created similar crop view.
I have obtained CGPoint of four corners.
But How can I obtained cropped image in slant.
Please provide me some suggestions if possible.
This is a perspective transform problem. In this case they are plotting a 3D projection in a 2D plane.
As, the first image has selection corners in quadrilateral shape and when you transform it in a rectangular shape, then you will either need to add more pixel information(interpolation) or remove some pixels.
So now actual problem is to add additional pixel information to cropped image and project it to generate second image. It can be implemented in various ways:
<> you can implement it by your own by applying perspective tranformation matrix with interpolation.
<> you can use OpenGL .
<> you can use OpenCV.
.. and there are many more ways to implement it.
I had solved this problem using OpenCV. Following functions in OpenCV will help you to achieve this.
cvPerspectiveTransform
cvWarpPerspective
First function will calculate transformation matrix using source and destination projection coordinates. In your case src array will have values from CGPoint for all the corners. And dest will have rectangular projection points for example {(0,0)(200,0)(200,150)(0,150)}.
Once you get transformation matrix you will need to pass it to second function. you can visit this thread.
There may be few other alternatives to OpenCV library, but it has good collection of image processing algorithms.
iOS application with opencv library is available at eosgarden.
I see 2 possibilities. The first is to calculate a transformation matrix that slants the image, and installing it in the CATransform3D property of your view's layer.
That would be simple, assuming you knew how to form the transformation matrix that did the stretching. I've never learned how to construct transformation matrixes that stretch or skew images, so I can't be of any help. I'd suggest googling transformation matrixes and stretching/skewing.
The other way would be to turn the part of the image you are cropping into an OpenGL texture and map the texture onto your output. The actual texture drawing part of that would be easy, but there are about 1000 kilos of OpenGL setup to do, and a whole lot to learning in order to get anything done at all. If you want to pursue that route, I'd suggest searching for simple 2D texture examples using the new iOS 5 GLKit.
Using the code given in Link : http://www.hive05.com/2008/11/crop-an-image-using-the-iphone-sdk/
Instead of using CGRect and CGContextClipToRect Try using CGContextEOClip OR CGContextClosePath
Though i havnt tried this... But i have tried drawing closed path using CGContextClosePath on TouchesBegan and TouchesMoved and TouchesEnd events.
Hope this can give more insight to your problem...