Ask Your Question

1'''s profile - activity

2020-12-17 03:57:18 -0600 received badge  Nice Question (source)
2020-12-17 03:57:08 -0600 received badge  Popular Question (source)
2016-06-02 14:56:13 -0600 received badge  Notable Question (source)
2015-01-27 02:25:19 -0600 received badge  Popular Question (source)
2013-08-08 18:34:44 -0600 asked a question Using getThreshVal_Otsu_8u in OpenCV4Android

Is there any way to get the optimal threshold value for an image, as found with getThreshVal_Otsu_8u(), from OpenCV4Android? If not, could this be included in a future release?

2013-07-07 17:58:05 -0600 asked a question Froyo-exclusive XML exception loading SVM dataset

I use the following code to load an SVM dataset stored at res/raw/dataset.xml: it copies the dataset from the APK to a particular folder on the file system once, and then loads it from there every subsequent time. As far as I know, there's no way to directly load a file from inside the APK.

File datasetDirectory = ((Activity) getContext()).getApplication().getDir("dataset", Context.MODE_PRIVATE);
File datasetFile = new File(datasetDirectory, "dataset.xml");
if (!datasetFile.exists()) { 
    try {
        InputStream is = getResources().openRawResource(R.raw.dataset);
        FileOutputStream os = new FileOutputStream(datasetFile);
        byte[] buffer = new byte[4096];
        int bytesRead;
        while ((bytesRead = is.read(buffer)) != -1) os.write(buffer, 0, bytesRead);
        is.close();
        os.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
svm.load(datasetFile.getAbsolutePath());

This code has worked on all devices, except for my only Froyo (API level 8) beta tester, who receives an error in svm.load(). Unfortunately, because I don't have access to the phone, I can't see whether the file was accurately copied.

E/AndroidRuntime(1630): CvException [org.opencv.core.CvException: ....\modules\core\src\persistence.cpp:2257: error: (-212) /data/data/com.myapp/app_dataset/dataset.xml(0): Valid XML should start with '<?xml ...?>' in function void icvXMLParse(CvFileStorage*)

What is the cause of this error? Is there another way to load the dataset that avoids this error?

2013-06-21 07:43:01 -0600 commented answer Disable CPU parallelization

Thanks very much!

2013-06-21 00:00:05 -0600 received badge  Student (source)
2013-06-20 19:26:24 -0600 received badge  Editor (source)
2013-06-20 19:25:52 -0600 asked a question Disable CPU parallelization

How can I benchmark OpenCV on Windows (Visual Studio) with CPU parallelization disabled? Is this possible without rebuilding the libraries? Should I insert an #undef HAVE_PARALLEL_FRAMEWORK somewhere? I haven't noticed a CMake option to disable compilation with the Parallel Patterns Library, among other parallel frameworks.

2013-06-19 15:59:22 -0600 commented answer Building OpenCV for GPU with CMake - cannot open file

Now I'm getting a whole bunch of sub-builds failing with fatal error C1033: cannot open program database '[OpenCV path]\bin\debug\opencv_[library name]249d.pdb' and error LNK2019: unresolved external symbol "public: static struct CUstream_st * __cdecl cv::gpu::StreamAccessor::getStream(class cv::gpu::Stream const &amp;)".

2013-06-19 13:18:53 -0600 commented answer Building OpenCV for GPU with CMake - cannot open file

Thanks, and thanks for the tip regarding the master branch also!

2013-06-19 13:18:26 -0600 received badge  Supporter (source)
2013-06-19 13:18:26 -0600 received badge  Scholar (source)
2013-06-18 12:32:25 -0600 asked a question Building OpenCV for GPU with CMake - cannot open file

I'm building OpenCV for CUDA 5.0 with CMake and Visual Studio 2010 based on this tutorial and many of the sub-builds are failing with the error

30>LINK : fatal error LNK1104: cannot open file '..\..\lib\Debug\opencv_gpuarithm249d.lib'

How can I debug or fix this error?

2012-08-13 12:59:32 -0600 asked a question OpenCV for Android

I created a new Android application with an activity called Start. I then went to project properties and added OpenCV as a library. Here's the code for the activity (Start.java):

package com.test;

import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;

import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.view.Menu;

public class Start extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start);

        Mat Image = Highgui.imread("/image.jpg");
        if (Image == null) {
            AlertDialog ad = new AlertDialog.Builder(this).create(); 
            ad.setMessage("Fatal error: can't open /image.jpg!");  
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_start, menu);
        return true;
    }
}

And here's the log:

08-13 12:26:14.791: E/Trace(1067): error opening trace file: No such file or directory (2)
08-13 12:26:15.191: W/dalvikvm(1067): No implementation found for native Lorg/opencv/highgui/Highgui;.imread_1:(Ljava/lang/String;)J
08-13 12:26:15.191: D/AndroidRuntime(1067): Shutting down VM
08-13 12:26:15.191: W/dalvikvm(1067): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
08-13 12:26:15.201: E/AndroidRuntime(1067): FATAL EXCEPTION: main
08-13 12:26:15.201: E/AndroidRuntime(1067): java.lang.UnsatisfiedLinkError: Native method not found: org.opencv.highgui.Highgui.imread_1:(Ljava/lang/String;)J
08-13 12:26:15.201: E/AndroidRuntime(1067):     at org.opencv.highgui.Highgui.imread_1(Native Method)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at org.opencv.highgui.Highgui.imread(Highgui.java:324)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at com.test.Start.onCreate(Start.java:18)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.Activity.performCreate(Activity.java:5008)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.os.Looper.loop(Looper.java:137)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at android.app.ActivityThread.main(ActivityThread.java:4745)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at java.lang.reflect.Method.invokeNative(Native Method)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at java.lang.reflect.Method.invoke(Method.java:511)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-13 12:26:15.201: E/AndroidRuntime(1067):     at ...
(more)