12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package com.epson.cameracopy.device;
- import com.epson.mobilephone.common.wifidirect.ActivityControlWiFi;
- import org.opencv.videoio.Videoio;
- import java.util.Iterator;
- public class PreviewResolutionSelector {
- static SizeWrapper selectSize01(double d, Iterable<SizeWrapper> iterable, int i, int i2) {
- int score01;
- if (iterable == null || d < 1.0d) {
- return null;
- }
- int i3 = 0;
- SizeWrapper simpleSize = new SimpleSize(0, 0);
- for (SizeWrapper next : iterable) {
- int width = next.getWidth();
- int height = next.getHeight();
- if (width <= i && height > 0 && Math.abs(((width) / (height)) - d) < 0.05d && i3 < (score01 = getScore01(height, i2))) {
- simpleSize = next;
- i3 = score01;
- }
- }
- if (simpleSize.getWidth() <= 0) {
- return null;
- }
- return simpleSize;
- }
- static int getScore01(int i, int i2) {
- if (i < 400 || i > i2) {
- return 0;
- }
- if (i <= 600) {
- return ((i - 400) * 5) + 9000;
- }
- return i2 <= 600 ? ActivityControlWiFi.SCANNING_TIMEOUT : (((i - Videoio.CAP_UNICAP) * -1000) / (i2 - Videoio.CAP_UNICAP)) + ActivityControlWiFi.SCANNING_TIMEOUT;
- }
- static SizeWrapper selectSize02(double d, Iterable<SizeWrapper> iterable, int i, int i2) {
- if (iterable == null || d < 1.0d) {
- return null;
- }
- Iterator<SizeWrapper> it = iterable.iterator();
- if (!it.hasNext()) {
- return null;
- }
- SizeWrapper next = it.next();
- double score03 = getScore03(next.getWidth(), next.getHeight(), i, i2, d);
- while (it.hasNext()) {
- SizeWrapper next2 = it.next();
- double score032 = getScore03(next2.getWidth(), next2.getHeight(), i, i2, d);
- if (score03 < score032) {
- next = next2;
- score03 = score032;
- }
- }
- return next;
- }
- static double getScore03(int i, int i2, int i3, int i4, double d) {
- int score02 = i <= i3 ? getScore02(i2, i4) : 0;
- if (score02 <= 0) {
- return 0.0d;
- }
- return (score02) * getAspectScore((i) / (i2), d);
- }
- static int getScore02(int i, int i2) {
- int score01 = getScore01(i, i2);
- if (score01 > 0) {
- return score01;
- }
- if (i >= 200 && i < 400) {
- return ((i - 200) * 90) / 2;
- }
- return 0;
- }
- static double getAspectScore(double d, double d2) {
- double abs = (Math.abs(d2 - d) * -0.5d) + 1.0d;
- if (abs < 0.0d) {
- return 0.0d;
- }
- return abs;
- }
- }
|