Windows 10 MediaClip rotation - windows-10-universal

How can I get video file rotation information using Windows 10 universal platform API?
For instance I have a video of size 1920 x 1080, rotated 90, so effectively it is 1080 x 1920.
The MediaElement control renders fine the video but during processing pipeline one of the steps is affected by this rotation and I need to detect this situation.
Sample MediaInfo from the source file is here:

I couldn't find any way to discover it.
But I have found a workaround, by using this piece of code:
private async Task<bool> CheckVideoFileRotated(StorageFile file)
{
var profile = await MediaEncodingProfile.CreateFromFileAsync(file);
var mediaClip = await MediaClip.CreateFromFileAsync(file);
var videoProp = mediaClip.GetVideoEncodingProperties();
return profile.Video.Width == videoProp.Height &&
profile.Video.Height == videoProp.Width;
}
I was able to detect if the rotation is in place. Luckily I don't need more specific information if it is 90 or 270 degrees.

Related

android webrtc rotate VideoFrame

I try below code to rotate VideoFrame by 90 degree but it doesn't work:
private VideoFrame rotateFrame(VideoFrame inVideoFrame) {
VideoFrame outVideoFrame = new VideoFrame(
inVideoFrame.getBuffer(),
90, inVideoFrame.getTimestampNs());
return outVideoFrame;
}
What's correct logic to rotate a videoFrame?
I have same problem but your code it's work for me.
I publish stream to Wowza Streaming Engine using webRTC and I try to debug my code while video frame publish to wowza. The orientation is 270. When I received this orientation back from service. it's 0 I try to change it before pass this frame to SurfaceViewRenderer. It's work.
remoteVideoTrack.addSink {
remoteView?.onFrame(VideoFrame(it.buffer, 270, -1))
}

can I use the codename one camera kit library to take a picture automatically from the code?

I'm new to using codename one and I can not understand how we can take a picture from the camera using captureImage (); from the camerakit library.
I know it's possible with the Capture API (Capture.capturePhoto ();) but this library uses an application to take the photo and I want to do this directly
I created a button :
FloatingActionButton capture_button =
FloatingActionButton.createFAB(FontImage.MATERIAL_CAMERA);
capture_button.bindFabToContainer(hi, CENTER, BOTTOM);
capture_button.addActionListener(e -> {
ck.captureImage();
.............
and after that I tried to get my picture from the onImage function but it does not work.
#Override
public void onImage(CameraEvent ev) {
try {
byte[] jpegData = ev.getJpeg();
String str = new String(jpegData);
InputStream stream = FileSystemStorage.getInstance().openInputStream(jpegData);
OutputStream out = Storage.getInstance().createOutputStream("MyImage.jpg");
Util.copy(stream, out);
Util.cleanup(stream);
Util.cleanup(out);
StorageImage out = StorageImage.create("MyImage.jpg", jpegData, -1, -1);
............................
}
the byte array is empty. Help please.
Camera Kit broke a bit after its release due to changes in Camera Kit which is still not 1.0 level. This is tracked in this issue. Camera kit was supposed to reach 1.0 status months ago but still hasn't reached that point. We
are waiting for it to be at 1.0 level so we can make fixes against a stable version.
We also need a bit of time/resources to do that work which is something we are sorely lacking.

Finding eye position on camera using camera2 api android

Below are my code snippet to get faces on camera using camera2 api. In that I am able to get eye position only for few devices. Rest of them returning NULL values. Is there a way to find eye position in camera using camera2 api?
Integer mode = result.get(CaptureResult.STATISTICS_FACE_DETECT_MODE);
Face[] faces = result.get(CaptureResult.STATISTICS_FACES);
if(faces != null && mode != null) {
if (faces.length > 0) {
Rect rect = faces[0].getBounds();
Log.e("tag", "faces : leftEye" + faces[0].getLeftEyePosition());
Log.e("tag", "faces : RightEye" + faces[0].getRightEyePosition());
}
}
Face detection is a feature that needs to be supported by the underlying camera module and is not related with Android frameworks. Hence your code works in certain devices and fails in rest. I believe Android framework doesn't have any explicit API for Face Detection.

OpenCV Capture from external camera

I'm currently writing an real time application using OpenCV and in the following case:
I'm trying to capture an image from a HDV camera plugged in firewire 800.
I have tried to loop on index used on cvCaptureFromCam,
but no camera can't be found (except the webcam).
there is my code sample, it loop on index (escaping 0 cause it's the webcam's index) :
CvCapture* camera;
int index;
for (index = 1; index < 100; ++index) {
camera = cvCaptureFromCAM(index);
if (camera)
break;
}
if (!camera)
abort();
On any time it stops on the abort.
I'm compiling on OSX 10.7 and I have tested :
OpenCV 1.2 private framework
OpenCV 2.0 private framework (found here : OpenCV2.0.dmg)
OpenCV compiled by myself (ver. 2)
I know that the problem is knowned and there is a lot of discussion about this,
but I'm not able ti find any solution.
Does anyone have been in the same case ?
Regards.
To explicitly select firewire, perhaps you can try to add 300 to your index? At least in OpenCV 2.4, each type of camera is given a specific domain. For example, Video4Linux are given domain 200, so 200 is the first V4L camera, 201 is the second, etc. For Firewire, the domain is 300. If you specify an index less than 100, OpenCV just iterates through each of its domains in order, which may not be the order you expect. For example, it might find your webcam first, and never find the firewire camera. If this is not the issue, please accept my appologies.
index should start at 0 instead of 1.
If that doesn't work, maybe your camera is not supported by OpenCV. I suggest you check if it is in the compatibility list.

Corona SDK Cross Device Screen Resolution

This is going to be one of those awkward questions looking for an answer that probably doesn't exist, but here goes.
I've been developing some simple games using Corona and whilst the functionality seems to work pretty well across most of the physical devices I have tested on, the one main issue is the layout. I know you can't really build for every single device perfectly, but I'm wondering if there is a common method to make an app look good across as many screens as possible. I have access to these devices
iPad 1 & 2: 4:3 (1.33)
iPhone 960 × 640 3:2 (1.5)
iPhone 480x320 3:2 (1.5)
Galaxy Nexus 16:9 (1.77)
From what I have seen, people aim to use 320x480 as a scaled resolution and then let Corona upscale to the correct device resolution (with any #2x images as required) but this leads to letterboxing or cropping depending on the config.lua scale setting. Whilst it does scale correctly, having a letterbox isn't great.
So would I be best to not specify a width&height in the config file, but instead to use some sort of screen check at first to look for 1.33 / 1.5 / 1.77 aspect ratios? Surely with the whole point of Corona SDK, there would be some sort of 'typical' setup that developers use for the start of any new project?
Thank you
It seems that I have found a pretty good solution based on this forum post on the Ansca website: http://developer.anscamobile.com/forum/2012/03/12/understanding-letterbox-scalling
In summary, the config.lua should look like this:
application = {
content = {
width = 320,
height = 480,
scale = "letterbox",
xAlign = "center",
yAlign = "center",
imageSuffix = {
["#2x"] = 2,
},
}
}
Create background images at 360*570 for older devices. 320x480 screens will crop the image slightly and it will scale nicely for older Android devices.
Create background images at 1140*720 for iPad and iPhone retina - again these will scale on Android and be slightly cropped on iOS.
As an example, where you would normally create a 320x480 image and display it with:
local bg = display.newImageRect("bg.png",320x480)
bg.x = display.contentWidth/2
bg.y = display.contentHeight/2
.. instead create a 360x570 background and use the following code:
local bg = display.newImageRect("bg.png",360x570)
bg.x = display.contentWidth/2
bg.y = display.contentHeight/2
This is just a summary, so check the link for more detailed instructions.
Well, you CAN use a number slightly off 2 for the scaling if you want correct images for the different devices. Ex:
application =
{
content =
{
width = 640,
height = 960,
scale = "zoomEven",
imageSuffix =
{
["-iphone3"] = 0.5,
["-ipad2"] = 1.066,
["-ipad3"] = 2.133,
},
}
}
In which "background.png" would be a 640x960 image for the iphone4, while "background-iphone3.png" would be 320x480 (you don´t need this, but it will reduce memory requirement for iphone3 applications). "background-ipad3.png" would need to be 1536x2048 (and half that for -ipad2).
Of course it doesn´t solve the aspect ratio for screen positioning, but it solves it for all other gfx related problems. Remember to use display.newImageRect, not display.newImage or you won´t see any difference.

Resources