Ask Your Question

Jian.Xi's profile - activity

2016-03-31 03:51:02 -0600 received badge  Enthusiast
2016-03-30 09:33:09 -0600 commented question What is the best practice for cropping the positive examples to train a HOG classifier?

Just as i tried(,maybe not the best practise), at first i used some cropping tools( you can Google it) to crop your positive or negative Training samples. Of course you should try to hold the aspect ratoin as good as you can. After Training your model with just cropped Images you can use your model than, go get more Trainings samples if it works. Just repeat it one more times, you can get enought samples. Hope it helps you.

2016-03-30 09:18:52 -0600 commented question java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/",

It the SDK provides the corresponding .jar file which you need, you can just copy it from SDK Folders to the Folder of your app.

2016-03-30 06:35:59 -0600 answered a question What is the way to save / load an instance of ANN_MLP in java.

As i tried, I call the JNI to load the model in c++, you can have a look at this link if you are still stuck at this problem:link text
After loading every Parameters of MLP is OK, but I've no idea how to save it in Java in converting the MLP pointer to jlong. Alternative I'm trying to use android sdk 2.4.11, for there is a load function available just like below Shows:

public  void load(String filename, String name)

    load_0(nativeObj, filename, name);


I'll post it again if it works. Jian

2016-03-26 08:01:22 -0600 asked a question Android 3.1 ANN_MLP HoG Descriptor

Hello everyone,

I'm working now at a pattern recognition Project and using ANN_MLP. I trained this model at frist with Opencv3.1 and using HoG as feature extractor in Windows and after that I was trying to load in it in Android. For Android I use the OpenCV-3.1.0-android-sdk. I've googled and it shows that since Java opencv 2.4 there is no load method for StatModel object. So i tried to load it with JNI. Here I have two questions:

1. When i create a HoG descriptor instance using the following codes,

HOGDescriptor mHoGDescriptor = new HOGDescriptor(_winSize, _blockSize, _blockStride, _cellSize, _nbins);

========================================================== [I got the fatal exception:]

java.lang.UnsatisfiedLinkError: Native method not found: org.opencv.objdetect.HOGDescriptor.HOGDescriptor_1:(DDDDDDDDI)J
at org.opencv.objdetect.HOGDescriptor.HOGDescriptor_1(Native Method)
at org.opencv.objdetect.HOGDescriptor.<init>(
at com.example.jian.reader.FeatureEvaluator$HoGFeature.<init>(
at com.example.jian.reader.MainActivity.initializeModels(
at com.example.jian.reader.MainActivity.onCreate(


2. In JNI loading model function, I use this method

JNIEXPORT jlong JNICALL Java_com_example_jian_reader_BridgeNativeModel_nativeCreateObject
  (JNIEnv *jenv, jclass, jstring jFileName){

    LOGD("Java_com_example_jian_reader_BridgeNativeModel_nativeCreateObject enter");

    const char* jnamestr = jenv->GetStringUTFChars(jFileName, NULL);
    string stdFileName(jnamestr);
    jlong result = 0;
    LOGD("jnamestr %s", jnamestr);

        Ptr<ml::ANN_MLP> model = Algorithm::load<ml::ANN_MLP>(stdFileName);
        if(model != NULL){
            LOGD("Model load successed");
            string schema = model->getDefaultName();
            Mat layers = model->getLayerSizes();
            int TrainingMethod = model->getTrainMethod();

            LOGD("schema:%s ", schema.c_str());
            LOGD("layers rows:%d ", layers.rows);
            for (size_t i = 0; i < layers.rows; i++)
                LOGD("\t[Layers Size: %d]", i);
                for (size_t j = 0; j < layers.cols; j++)
                    LOGD(" has %d nodes",<int>(i, j));
            LOGD("TrainingMethod:%d ", TrainingMethod);
            LOGD("[Number of iterations/elements::%d ]", model->getTermCriteria().maxCount);

        result = <jlong>(model);

========================================================== So I don't konw how to covert ANN_MLP instance to jlong, this is the compliling error

Reader/app/src/main/jni/BridgeNativeModel_jni.cpp: In function 'jlong Java_com_example_jian_reader_BridgeNativeModel_nativeCreateObject(JNIEnv*, jclass, jstring)':
Reader/app/src/main/jni/BridgeNativeModel_jni.cpp:55:18: error: expected primary-expression before '<' token
         result = <jlong>(model);

Any Inputs will be appreciated! Jian