Stream mjpeg (or any other format/method) from my Pi 3 camera to another server in AWS

I am looking to “tunnel”, “forward”, “bridge” an mjpeg stream from mi Raspberry Pi 3 to a server I have on AWS (Linux). I have currently tried the UV4L packages to stream video in my LAN and I have succeeded.

The problem I have is that my router is behind a private IP 10.100.xx.x and I have no control over the Modem my router is connected to since I live in an apartment complex (and they will obviously refuse to give me access to it) and by what I read here I think there is no way I can connect my pi to the outside world (as explained by klricks @ Thu Apr 24, 2014 12:38 pm in that thread).

Therefore, I have decided that my way to circumvent this problem is to somehow stream (not necessarily using UV4L or MJPEG, any other protocol/package/way is fine) my pi camera’s video to my server hosted on AWS. Then my server will act as a mediator/proxy, and will serve the stream to other clients. I don’t really need anything fancy, I am looking for something that works (but I am open to fancier solutions).

I have used nginx for some stuff, so I was wondering if I could stream it over that… Or if there are any open source video streaming solutions that can be installed in a server…

Do any of you have any suggestions?

Thank you for your help in advance!

Cheers!

Performance of generic VS non-generic method (array generating function)

I’m trying to improve performance for a generic function that turns a string into a multidimensional array.

Expected input:

  • A string that was generated by the function Arrays.deepToString().
  • The original array had no null values and did not contain arrays of length 0.
  • The array can have any number of dimensions from 1 to 200.
  • Sub-arrays may have different length (e.g. arr[0].length != arr[1].length)

The function converts the values into the requested data type, which may be any primitive variable or String.

private static String[] arraySeparators;
private static Class[] arrayTypes;

public static  Object reverseDeepToString(String str, Class dataType){
    int dimensions = 0;
    while(str.charAt(dimensions) == '[')
        dimensions++;

    arraySeparators = new String[dimensions + 1];
    String separator = ", ";
    for(int x = 2; x <= dimensions; x++)
        arraySeparators[x] = separator = ']' + separator + "\[";

    arrayTypes = new Class[dimensions + 1];
    Class temp = arrayTypes[2] = Array.newInstance(dataType, 0).getClass();
    for(int x = 3; x <= dimensions; x++)
        arrayTypes[x] = temp = Array.newInstance(temp, 0).getClass();

    str = str.substring(dimensions, str.length() - dimensions);
    Object r = createArrayRecursive(str, dimensions, dataType);

    arraySeparators = null;
    arrayTypes = null;
    return r;
}

private static  Object createArrayRecursive(String str, int dimension, Class dataType){

    if(dimension == 1){
        String[] s = str.split(", ");
        Object result = Array.newInstance(dataType, s.length);
        for(int x = 0; x < s.length; x++){
            if(dataType == String.class) Array.set(result, x, s[x]);
            else if(dataType == int.class) Array.set(result, x, Integer.parseInt(s[x]));
            else if(dataType == double.class) Array.set(result, x, Double.parseDouble(s[x]));
            else if(dataType == float.class) Array.set(result, x, Float.parseFloat(s[x]));
            else if(dataType == long.class) Array.set(result, x, Long.parseLong(s[x]));
            else if(dataType == boolean.class) Array.set(result, x, Boolean.parseBoolean(s[x]));
            else if(dataType == short.class) Array.set(result, x, Short.parseShort(s[x]));
            else if(dataType == byte.class) Array.set(result, x, Byte.parseByte(s[x]));
            else if(dataType == char.class) Array.set(result, x, s[x].charAt(0));
        }
        return result;
    }
    String[] s = str.split(arraySeparators[dimension]);
    Object arr = Array.newInstance(arrayTypes[dimension], s.length);

    for(int x = 0; x < s.length; x++)
        Array.set(arr, x, createArrayRecursive(s[x], dimension - 1, dataType));

    return arr;
}

The problem is that these workarounds to deal with limitations of generic types are slowing down the function significantly compared to the non-generic equivalent:

private static String[] arraySeparators;

public static Object reverseDeepToString(String str){
    int dimensions = 0;
    while(str.charAt(dimensions) == '[')
        dimensions++;
    arraySeparators = new String[dimensions + 1];
    String separator = ", ";
    for(int x = 2; x <= dimensions; x++)
        arraySeparators[x] = separator = ']' + separator + "\[";
    str = str.substring(dimensions, str.length() - dimensions);
    return createArrayRecursive(str, dimensions);
}

private static Object createArrayRecursive(String str, int dimension){

    if(dimension == 1){
        String[] s = str.split(", ");
        double[] result = new double[s.length];
        for(int x = 0; x < s.length; x++)
            result[x] = Double.parseDouble(s[x]);
        return result;
    }
    String[] s = str.split(arraySeparators[dimension]);
    int[] lengths = new int[dimension];
    lengths[0] = s.length;
    Object arr = Array.newInstance(double.class, lengths);

    for(int x = 0; x < s.length; x++)
        Array.set(arr, x, createArrayRecursive(s[x], dimension - 1));

    return arr;
}

My question is: is there a way to make a generic function as efficient as a non-generic function, or at least get very close to it?

The only alternative I have in mind is creating lots of copies of the non-generic function (one for each variable type), and have a main function choosing which non-generic function to use, but that will be a very long and ugly code that I try to avoid:

public static  Object reverseDeepToString(String str, Class dataType){

    if(dataType == int.class) return reverseDeepToString_int(str);
    if(dataType == double.class) return reverseDeepToString_double(str);
    if(dataType == long.class) return reverseDeepToString_long(str);
    if(dataType == String.class) return reverseDeepToString_string(str);
    if(dataType == boolean.class) return reverseDeepToString_boolean(str);
    ...
}

What is the degree of freedom of semiparametric method for mixture distribution

In the semiparametric method for density analysis, I want to compare one component semiparametric mixture distribution and two component mixture distribution. Semiparametric here means the shape of the distribution is total flexible but symmetric, an even pdf. As there is no variables in the semi method, the pdf is quite flexible, what is the degree of freedom in this question?

What is the degree of freedom of semiparametric method for mixture distribution

In the semiparametric method for density analysis, I want to compare one component semiparametric mixture distribution and two component mixture distribution. Semiparametric here means the shape of the distribution is total flexible but symmetric, an even pdf. As there is no variables in the semi method, the pdf is quite flexible, what is the degree of freedom in this question?

Bonferroni-type corrections and Fisher Method Meta-analysis

I’m not an expert on the field, but I need to know more about how to combined multiple significance test p-values after a two sample Kolmogorov Smirnov (KS)test on two distributions.

But I have two cases: 1) a model where I can generate as many realizations I wish and 2) only one (or a few) observed realization.

1) I run multiple KS tests, each test gives me a p-value: I used the Fisher Method and everything goes as expected in literature Fisher tesi in CrossValidate and Fisher test in CrossValidated(unifiorm distribution of p-values if hypothesis cannot be reject).

Now, since I could complicate the model in different ways, I was wondering if I can also use the Bonferroni-Holm correction Wiki-page on method for the same dataset with multiple p-values (meta-analysis).

And which is actually the difference between Bonferrroni-type corrections and Fisher-type ones (or Stouffer type), more in terms when to use them, which are the requirements and conditions and limitations. For example multiple comparison is indented for different tests with different hypothesis, or inter-dependence among tests

2) what changes about the methods, if I have only 1 observed sequence and I use Bootstrapping o permutation test to artificially created several sequences and making again K-S stests and several p-values again.

Thanks