Activate the back camera on WP8 Device - windows

I'm trying to do something very simple: implement a program that activates the back camera of my WP8 device. Could anyone help me do that?

If so you could try using the PhotoCamera class in order to capture images. I'm not pretty sure whether you'll be able to open the native Camera app of the device.
References:
How to access the camera from my Windows Phone 8 app (XAML and C#) and save the taken picture in a determined folder?
Sample from MSDN
Minimal Camera app in Windows Phone

Related

What kind of UWP app to make for Windows camera filtering app?

The idea is to create an app that can read any local camera device, filter it, then have a new camera "virtual device" other apps can use as input.
How can this be done with UWP?
How can this be done with UWP?
Only the first part of your requirements could be done in UWP apps - can read any local camera device, filter it. UWP could connect to the local camera for capturing photo and video. You could also modify the media content as you want. More information could be known here: Camera - UWP.
But UWP apps are not able to send the camera to other apps as a virtual device. You might need to try other ways like win32 to achieve this.

CameraCaptureTask in Windows Phone 8 - auto saves to camera roll

I have an existing application developed for Windows Phone 7, which uses CameraCaptureTask.
The captured image is returned back to the app, which will be processed for grayscale conversion.
While testing the same app (same binary to be precise) in Windows Phone 8 Lumia 920, I figured that a copy of all the images captured through the CameraCaptureTask are saved in "camera roll" folder.
This is a bit annoying as the users of my app are not expecting the captured images crowding the "camera roll" folder. I looked up the documentation http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394006(v=vs.105).aspx and found the below quote,
On Windows Phone 8, if the user accepts a photo taken with the camera capture task, the photo is automatically saved to the phone’s camera roll. On previous versions of Windows Phone, the photo is not automatically saved.
So far I couldn't find a way to avoid this case in Windows Phone 8.
Is there a way to turn off this feature before calling the CameraCaptureTask's Show() method in Windows Phone 8?
No. This is a consumer feature request implemented on WP8 that's transparent to developers. The usecase here is that a consumer uses the CameraCaptureTask to line up a perfect shot, doesn't use it an app for whatever reason and can't find it ever again later.
As a side-note, I actually had this happen a few times to me when using various twitter and photo editing apps and it's quite annoying.
Makes no sense. CameraCaptureTask was created to allow apps to capture photos for the app use, not for users to push them into Camera Roll. That is what Lenses are for (either custom code can write into camera roll as well).
It is not transparent to developers because one of my apps has just been removed from the WP8 market. They say because can cause "undesired upload of an app photo to skydrive".
Justin are you sure it isn't a bug? is it going to be fixed?
This forces me to break my development into 2 now: WP7 and WP8. I don't want that hassle right now...

Reflection failure when attempting to access Microsoft.Phone.Media.Extended

I am developing one Flash Light application in Silverlight for windows phone 8. Currently
I am deeply stuck in one issue for the use of "Microsoft.Phone.Media.Extended" assembly. Flash Light Application for Windows phone 7 is already live in Windows Phone Marketplace and it is working very fine for Windows Phone 7 but it is not working for Windows Phone 8 because of "Microsoft.Phone.Media.Extended" dll.
After converting WP7 app into wp8 and run then I got this type of error message:
Could not load file or assembly 'Microsoft.Phone.Media.Extended,Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e' or one of its dependencies. The system can not find file specific."
According to following link for Windows Phone-specific features:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206947(v=vs.105).aspx
If you were using reflection to access the API in this assembly, because they were not publicly exposed, your app may fail on a Windows Phone 8 device. Remove the calls to this assembly and use the publicly exposed media API.
I an not understanding how to use publicly exposed media API. I used Microsoft.Phone.Media.Extended using reflaction in Windows Phone 7. Is there any direct method for accessing Microsoft.Phone.Media.Extended in Windows Phone 8 or other way to solve this?
Thanks.
==========================================================================
Edited Question:
Hi,
As per the thread, we used "VideoTorchMode" enumeration to make flashlight ON. As per that, I used AudioVideoCaptureDevice class using Windows.Phone.Media.Capture namespace with following code:
var objDevice = await AudioVideoCaptureDevice.OpenAsync(CameraSensorLocation.Back, AudioVideoCaptureDevice.GetAvailableCaptureResolution(CameraSensorLocation.Back).First());
objDevice .SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On);
I want to keep the flash light on but without capturing video. So, i have not initialized video capture code. The issue is, i don’t have WP8 yet and in simulator i am not able to test this.
Can any one confirm that once i put this code, my app will work as Flashlight-X where light will be on without blinking and also it will not get crashed in WP8.
Thanks
Microsoft.Phone.Media.Extended is a private API in WP7 that wasn't meant to be used by 3rd party developers. That API doesn't exist or works on WP8.
For WP8 flashlight use the AudioVideoCaptureDevice known property of VideoTorchMode=On. Also, make sure to handle failures like exceptions or devices that don't have a Camera Torch by showing a white screen.
Here's a code sample that turns on the camera flash on my Lumia 820 and Lumia 920:
var sensorLocation = CameraSensorLocation.Back;
try
{
// get the AudioViceoCaptureDevice
var avDevice = await AudioVideoCaptureDevice.OpenAsync(sensorLocation,
AudioVideoCaptureDevice.GetAvailableCaptureResolutions(sensorLocation).First());
// turn flashlight on
var supportedCameraModes = AudioVideoCaptureDevice
.GetSupportedPropertyValues(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchMode);
if (supportedCameraModes.ToList().Contains((UInt32)VideoTorchMode.On))
{
avDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On);
// set flash power to maxinum
avDevice.SetProperty(KnownCameraAudioVideoProperties.VideoTorchPower,
AudioVideoCaptureDevice.GetSupportedPropertyRange(sensorLocation, KnownCameraAudioVideoProperties.VideoTorchPower).Max);
}
else
{
ShowWhiteScreenInsteadOfCameraTorch();
}
}
catch(Exception ex)
{
// Flashlight isn't supported on this device, instead show a White Screen as the flash light
ShowWhiteScreenInsteadOfCameraTorch();
}
Make sure to add the required capabilities and requirements to your WP8 app when using the camera torch (ISV_Camera, Microphone, and ID_REQ_BACK_Camera).
What about getting this assembly from somewhere and adding it to your XAP directly (try asking on XDA developers)? This might work, if it's signed and not requiring any special capabilities.
If you use the new API to "record" a video, then using the VideoTorchMode enumeration might do just want you want to create a "flashlight" effect.

Adding a third camera

As my company has a special need of installing a third camera on a Windows Phone Mango, do you think this is possible to access to the camera using Mango's Camera API?
As far as I can see the PhotoCamera only has two constructures: PhotoCamera() and PhotoCamera(CameraType type). The "type" here can only Primary or FrontFacing so I guess we cannot do anything else here.
We don't get this issue on Android, as they have the interface of Camera.open(int cameraId), and the cameraId can be any id between 0 and Camera.getNumberOfCameras() - 1.
I'm a bit confused, as there's no way to "install" another camera. There is no USB host port on the device, nor is there any other harcware interface, so how would you connect the camera physically?
Even if you could connect physically, there's no way for anyone other than a phone OEM to create and install the drivers for said camera, so how would the OS enumerate it to the platform?
If you're an OEM, you've undoubtedly got a support channel directly with Microsoft where you could ask this, as no one outside that channel is going to have any idea. If you're not an OEM, there's simply no way to add a camera or any other (non-bluetooth) peripheral to the phone.

Accessing the camera in Windows Mobile 6 with PythonCE

I have a windows mobile device - HTC Touch Viva - and PythonCE installed on it. I want to capture the camera image using python script. I have ctypes in PythonCE, so was wondering if I could load the DLL that controls the camera and access those methods directly.
Please let me know if anyone has done this before.

Resources