How to choose the correct IMediaEncodingProperties from GetAvailableMediaStreamProperties(MediaStreamType.Photo) from MediaCapture? - windows-8

I used
IReadOnlyList<IMediaEncodingProperties> supportedResolutions = _mediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo)
to get resolutions.
So that i got 40 IMediaEncodingProperties.
In that first 18 IMediaEncodingProperties has Subtype as "YUY2", next 22 has Subtype "MJPG".
We will get 4 IMediaEncodingProperties for same resolution like for 640 × 480
First IMediaEncodingProperties
- supportedResolutions[0] {Windows.Media.MediaProperties.VideoEncodingProperties} Windows.Media.MediaProperties.IMediaEncodingProperties {Windows.Media.MediaProperties.VideoEncodingProperties}
- [Windows.Media.MediaProperties.VideoEncodingProperties] {Windows.Media.MediaProperties.VideoEncodingProperties} Windows.Media.MediaProperties.VideoEncodingProperties
Bitrate 147456000 uint
- FrameRate {Windows.Media.MediaProperties.MediaRatio} Windows.Media.MediaProperties.MediaRatio
Denominator 1 uint
Numerator 30 uint
Height 480 uint
+ PixelAspectRatio {Windows.Media.MediaProperties.MediaRatio} Windows.Media.MediaProperties.MediaRatio
ProfileId 0 int
+ Properties {Windows.Media.MediaProperties.MediaPropertySet} Windows.Media.MediaProperties.MediaPropertySet
Subtype "YUY2" string
Type "Video" string
Width 640 uint
+ Properties {Windows.Media.MediaProperties.MediaPropertySet} Windows.Media.MediaProperties.MediaPropertySet
Subtype "YUY2" string
Type "Video" string
Second IMediaEncodingProperties
- supportedResolutions[1] {Windows.Media.MediaProperties.VideoEncodingProperties} Windows.Media.MediaProperties.IMediaEncodingProperties {Windows.Media.MediaProperties.VideoEncodingProperties}
- [Windows.Media.MediaProperties.VideoEncodingProperties] {Windows.Media.MediaProperties.VideoEncodingProperties} Windows.Media.MediaProperties.VideoEncodingProperties
Bitrate 147456000 uint
- FrameRate {Windows.Media.MediaProperties.MediaRatio} Windows.Media.MediaProperties.MediaRatio
Denominator 1 uint
Numerator 15 uint
Height 480 uint
+ PixelAspectRatio {Windows.Media.MediaProperties.MediaRatio} Windows.Media.MediaProperties.MediaRatio
ProfileId 0 int
+ Properties {Windows.Media.MediaProperties.MediaPropertySet} Windows.Media.MediaProperties.MediaPropertySet
Subtype "YUY2" string
Type "Video" string
Width 640 uint
+ Properties {Windows.Media.MediaProperties.MediaPropertySet} Windows.Media.MediaProperties.MediaPropertySet
Subtype "YUY2" string
Type "Video" string
19th IMediaEncodingProperties
- supportedResolutions[18] {Windows.Media.MediaProperties.VideoEncodingProperties} Windows.Media.MediaProperties.IMediaEncodingProperties {Windows.Media.MediaProperties.VideoEncodingProperties}
- [Windows.Media.MediaProperties.VideoEncodingProperties] {Windows.Media.MediaProperties.VideoEncodingProperties} Windows.Media.MediaProperties.VideoEncodingProperties
Bitrate 221184000 uint
- FrameRate {Windows.Media.MediaProperties.MediaRatio} Windows.Media.MediaProperties.MediaRatio
Denominator 1 uint
Numerator 30 uint
Height 480 uint
- PixelAspectRatio {Windows.Media.MediaProperties.MediaRatio} Windows.Media.MediaProperties.MediaRatio
Denominator 1 uint
Numerator 1 uint
ProfileId 0 int
+ Properties {Windows.Media.MediaProperties.MediaPropertySet} Windows.Media.MediaProperties.MediaPropertySet
Subtype "MJPG" string
Type "Video" string
Width 640 uint
+ Properties {Windows.Media.MediaProperties.MediaPropertySet} Windows.Media.MediaProperties.MediaPropertySet
Subtype "MJPG" string
Type "Video" string
20th IMediaEncodingProperties
- supportedResolutions[19] {Windows.Media.MediaProperties.VideoEncodingProperties} Windows.Media.MediaProperties.IMediaEncodingProperties {Windows.Media.MediaProperties.VideoEncodingProperties}
- [Windows.Media.MediaProperties.VideoEncodingProperties] {Windows.Media.MediaProperties.VideoEncodingProperties} Windows.Media.MediaProperties.VideoEncodingProperties
Bitrate 221184000 uint
- FrameRate {Windows.Media.MediaProperties.MediaRatio} Windows.Media.MediaProperties.MediaRatio
Denominator 1 uint
Numerator 15 uint
Height 480 uint
+ PixelAspectRatio {Windows.Media.MediaProperties.MediaRatio} Windows.Media.MediaProperties.MediaRatio
ProfileId 0 int
+ Properties {Windows.Media.MediaProperties.MediaPropertySet} Windows.Media.MediaProperties.MediaPropertySet
Subtype "MJPG" string
Type "Video" string
Width 640 uint
+ Properties {Windows.Media.MediaProperties.MediaPropertySet} Windows.Media.MediaProperties.MediaPropertySet
Subtype "MJPG" string
Type "Video" string
What is the differents between these IMediaEncodingProperties. What should i use to capture a still photo?

It appears the only difference between those four are their Numerators and Bitrate. I am not sure if either of those properties come into play with Photo as I'd associate them only with video but to be safe perhaps grab the one with the largest bitrate and largest numerator/denominator ratio.

Related

VM error: revert in solidity while adding a uint8 to an int literal

I have this code:
function somePureFunction() public pure returns(uint256){
uint8 temp = 255;
return 2 + temp;
}
This code gives:
call to SimpleStorage.somePureFunction errored: VM error: revert.
revert
The transaction has been reverted to the initial state.
Note: The called function should be payable if you send value and the value you send should be less than your current balance.
But this works:
function somePureFunction() public pure returns(uint256){
return 2 + 255;
}
In particular your problem refers to value about temp that you give to this variable.
When you declare a variable with datatype uint8 you must to put inside it a value from 0 - 255 (255 excluded). For calculate the range of a specific uint, you can use this statement:
MaximumRange = 2*[numberOfBit]-1
Example:
Issue: I want know what is the range about uint32.
Expression = 2*32-1
Result = 0 - 4294967295
In your specific case, if you change this line:
uint8 temp = 255;
with this:
uint16 temp = 255;
it'll work successfully.
NOTE: You can change current datatype temp variable with other uint datatype like: uint16, uint32, uint64 and others. You must to keep in your mind the range of a single datatype and the value that you want to store inside the variable.

uint multiplication with fractions in solidity

I am trying to get a lower and upper threshold on a value in solidity.
function foo(uint value) public {
uint lower_threshold = value * 0.5;
uint upper_threshold = value * 1.5;
}
With the above code, I get the following error:
TypeError: Operator * not compatible with types uint32 and rational_const 1 / 2
My goal is to check that the value passed is within the threshold to perform some action. Is there a way to do this in Solidity?
As the documentions says Solidity does not fully support decimal operations yet. You have two options there.
You can convert .5 and 1.5 into multiplication and division operations. But as output will be uint you will have precision loss. Ex:
uint value = 5;
uint lower_threshold = value / 2;//output 2
uint upper_threshold = value * 3 / 2;//output 7
You can multiply value with some uint value so that performing
value / 2 won't have any precision loss. Ex:
uint value = 5;
uint tempValue = value * 10;//output 50
uint lower_threshold = tempValue / 2;//output 25
uint upper_threshold = tempValue * 3 / 2;//output 75
if(tempValue >= lower_threshold && tempValue <= lower_threshold) {
//do some stuff
}

Casting conversion of int to int32

I am working on pulling in rows from the Db and storing the results in a Slice/Array
I need to calculate the totalRecords & totalPages.
pseudoCode ::
perPage int32 := ( some number )
totalRecords := len(array)
totalPages := perPage/totalRecords
I keep getting this error.
terminal::
`invalid operation: perPage / totalRecords (mismatched types int32 and int)`
len(array) returns an int convert it to an int32 int32(len(array)) or convert perPage to an int

Converting GPS coordinates (latitude and longitude) to decimal

I am getting the latitude and longitude from GPS device. They look like 21081686N,079030977E
If I manually convert them to 21°08'16.86"N, 79°03'09.77"E and check on Google maps, the location is almost correct.
How do I convert these values in java and convert them to decimal accurately? Any JAVA libraries?
Thanks,
You shouldn't need a library, but rather just break up the strings into their component parts. Perhaps this will help. Please note I'm not a Java programmer so this syntax could very well be wrong. (Perhaps retag your question to Java)
By decimal I presume you mean decimal degrees and not ddd.mmss
// Object for Lat/Lon pair
public class LatLonDecimal
{
public float lat = 0.0;
public float lon = 0.0;
}
// Convert string e.g. "21081686N,079030977E" to Lat/Lon pair
public LatLonDecimal MyClass::convert(String latlon)
{
String[] parts = latlon.split(",");
LatLonDecimal position = new LatLonDecimal();
position.lat = convertPart(parts[0]);
position.lon = convertPart(parts[1]);
return position;
}
// Convert substring e.g. "21081686N" to decimal angle
private float MyClass::convertPart(String angle)
{
while (angle.length() < 10)
angle = StringBuffer(angle).insert(0, "0").toString();
int deg = Integer.parseInt( angle.substring(0,2) );
int min = Integer.parseInt( angle.substring(3,4) );
int sec = Integer.parseInt( angle.substring(5,6) );
int sub = Integer.parseInt( angle.substring(7,8) );
String hem = angle.substring(9);
float value = deg + min / 60.0f + sec / 3600.0f + sub / 360000.0f;
float sign = (hem == "S") ? -1.0 : 1.0; // negative southern hemisphere latitudes
return sign * value;
}

Convert float to int in Objective-C

How can I convert a float to int while rounding up to the next integer? For example, 1.00001 would go to 2 and 1.9999 would go to 2.
float myFloat = 3.333
// for nearest integer rounded up (3.333 -> 4):
int result = (int)ceilf(myFloat );
// for nearest integer (3.4999 -> 3, 3.5 -> 4):
int result = (int)roundf(myFloat );
// for nearest integer rounded down (3.999 -> 3):
int result = (int)floor(myFloat);
// For just an integer value (for which you don't care about accuracy)
int result = (int)myFloat;
Use ceil function:
int intValue = (int)ceil(yourValue);
You can use following C methods to get the int values from different dataTypes.
extern float ceilf(float);
extern double ceil(double);
extern long double ceill(long double);
These functions return float, double and long double respectively. But the job of these function is to get ceil of or floor of the argument. As in http://en.wikipedia.org/wiki/Floor_and_ceiling_functions
Then you can cast the return value to desired type like.
int intVariable = (int)ceilf(floatValueToConvert);
Hope it is helpful.
if we have float value like 13.123 to convert it into integer like 13
Code
float floatnumber=13.123; //you can also use CGFloat instead of float
NSLog(#"%.f",floatnumber); // use for print in command prompt