Ask Your Question

maythe4thbewithu's profile - activity

2016-07-22 00:03:15 -0600 received badge  Enlightened (source)
2015-09-23 10:29:03 -0600 answered a question OpenCV 3.0.0 and FFMPEG building errors

use newest source from here will solve the problem.

you might also need this post

2015-09-23 10:26:48 -0600 answered a question Error building OpenCV 3.0.0 with FFMPEG

1) use the opencv source from here

2) --> relocation R_X86_64_32 against `.rodata.str1.1' can not be used

this error comes from some of libraries used by ffpmeg do not compile with --enable-shared

most probably the libvpx, please use "make clean" first before you reset ./configure with --enable-shared

and recompile those libraries.

3) recompile ffmpeg with --enable-shared and others

4) recompile opencv

2014-01-02 02:11:25 -0600 answered a question Run failed

Just ask..

Have you add the the path of installed OpenCV files (especially libopencv_XXX.dll) to system variables ?

2013-12-19 10:01:17 -0600 commented answer OS X Mavericks/ OpenCV Issues

@jensenb gives a correct answer to this problem. May I ask how to specify using libstdc++ or libc++ ? I use CMake-gui to configure the OpenCV and "make" to build it. Any flag in CMake ? or I should do something when I "make" it ? Thanks.

2013-12-19 09:53:46 -0600 received badge  Supporter (source)
2013-11-14 22:55:55 -0600 answered a question opencv 2.4.6 cmake configure error. How to fix it?

I do not test these steps

but you may try

1) Update your SDK, from this http://www.microsoft.com/en-us/download/details.aspx?id=3138

or this http://www.microsoft.com/en-us/download/details.aspx?id=8279

and VS to SP1

SP1 will remove something important, so you need to do step 2 to fix it

2) install the bug-fix from

http://www.microsoft.com/en-us/download/details.aspx?id=4422


If after step 1 and 2, you still have the same problem

try (as suggested by Adi Shavit at -- http://stackoverflow.com/questions/14590947/cmake-configuring-fails-cl-exe-is-not-able-to-compile-a-simple-test-program )

1) Right-Click->Properties on cl.exe in your VS install directory (the exact path appears in the CMake error)

2) Choose the Compatibility Tab

3) Check "Run this program as administrator" in the "Privilege Level" box.

2013-10-10 17:46:14 -0600 received badge  Good Answer (source)
2013-10-10 05:28:25 -0600 received badge  Nice Answer (source)
2013-10-09 04:07:36 -0600 received badge  Teacher (source)
2013-10-08 22:59:52 -0600 answered a question Best way to apply a function to each element of Mat.

As suggested by Guanta below and http://answers.opencv.org/question/3730/how-to-use-parallel_for/

I compare 3 ways which are normal, TBB, and opencv_parallel.

( with 1920x1080 to 19200x10800 , uchar, single channel Mat under 2.3GHz Core i5 MBP )

The built in OpenCV ParallelLoopBody win !!

Here is the code,

#include <iostream>
#include <cmath>
#include <tbb/tbb.h>                                    // for tbb
#include <opencv2/highgui/highgui.hpp>    // ParallelLoopBody is included (core.hpp)

using namespace std ;
using namespace tbb ;
using namespace cv ;

// this class is for tbb, delete it if you don't needed it 
class parallel_pixel
{
private:
    uchar *p ;
public:
    parallel_pixel(uchar *ptr ) : p(ptr) { }

    void operator() ( const blocked_range<int>& r ) const
    {
        for ( int i = r.begin(); i != r.end(); i++ ) {
            p[i] = (uchar)cos( p[i] )  ;    // I just use cos()
        }
    }
} ;

// this class is for OpenCV ParallelLoopBody
class Parallel_pixel_opencv : public ParallelLoopBody
{
private:
    uchar *p ;
public:
    Parallel_pixel_opencv(uchar* ptr ) : p(ptr) {}

    virtual void operator()( const Range &r ) const
    {
        for ( register int i = r.start; i != r.end; ++i)
        {
            p[i] = (uchar)cos( p[i] )  ;
        }
    }
};


int main()
{
    int width = 1920 *3;
    int height = 1080 *3;

    // If too small nElements the tbb will take longer time, since tbb need to be started and copy
    int nElements = width*height ;     // only for single channel

    Mat src( Size(width,height) , CV_8UC1 ) ;       // for one_by_one run
    Mat old ;                                       // clone for tbb
    Mat old2 ;                                     // clone for ParallelLoopBody

    // just put some initial value
    int v = 0 ;
    for( int w = 0 ; w < src.rows ; ++w )
    {
        for( int h = 0 ; h < src.cols ; ++h )
        {
            src.at<uchar>(w,h) = saturate_cast<uchar>(v) ;
            v++ ;
        }
    }
    // initial end
    old = src.clone() ;    // save a copy
    old2 = src.clone() ;

    // --------- normal way ----------- 
    uchar* p1 = src.data ;    // p1 for normal way

    // normal way : one_by_one iteration
    // timing start
    for( int i = 0 ; i < nElements ; ++i )
    {
        p1[i] = (uchar)cos( p1[i] ) ;
    }
    // timing stop

    // --------- TBB way -----------
    task_scheduler_init init ;    // start tbb
    uchar* p2 = old.data ;    // p2 for tbb way

    // timing tbb start, 
    // parameter = 800 is testing on my computer has best performance

    parallel_for(blocked_range<int>(0, nElements, 800), parallel_pixel(p2) ) ;

    // timing tbb stop


    // --------- opencv way ----------
    uchar* p3 = old2.data ;

    // timing ParallelLoopBody start

    parallel_for_( Range(0,nElements) , Parallel_pixel_opencv(p3)) ;

    // timing ParallelLoopBody stop



    // checking if normal way has the same result as tbb way
    for( int i = 0 ; i < nElements ; ++i ) {
        if( p1[i] != p2[i] ) {
            cout << i << " tbb answer not match" <<  endl;
        }
        if( p1[i] != p3[i] )  {
            cout << i << " opencv answer not match" <<  endl;
        }
    }

    return 0;
}

The result is :

normal time: 754.778 ms

TBB time: 223.938 ms

opencv time: 200.656 ms

normal/tbb = 3.37048 (sorry, in last post I report 2.7 because my cpu is doing something else)

normal/opencv = 3.76155

2013-09-26 09:33:50 -0600 answered a question Grayscale avi to image

I check on Mac OS X 10.8.5 + OpenCV 2.4.6 ( gcc => Apple LLVM version 5.0 (clang-500.2.76) with Qt IDE)

It works fine. No crash, the 30 images can be dumped OK for both Suize and Forman video. program end normally.

I think the problem is not caused by OpenCV itself.

The problem maybe "You don't have the correct codec for this file".

Since codec is something independent from OpenCV.

As I know, you install codec into system, OpenCV use them.

The codec of the avi is "rawvideo", which is reported by FFmpeg (installed separately, not from OpenCV).

It seems I have correct codec on my system, because FFmpeg can dump jpg also normally.

here is the information from my FFmpeg of your 41.avi


configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-nonfree --enable-postproc --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-libtheora --enable-libvorbis --enable-libvpx --enable-shared --enable-mmx --arch=x86_64 --enable-swscale --enable-runtime-cpudetect --enable-pthreads --enable-avfilter --enable-libspeex --enable-libopenjpeg

libavutil 52. 46.100 / 52. 46.100

libavcodec 55. 33.100 / 55. 33.100

libavformat 55. 18.102 / 55. 18.102

libavdevice 55. 3.100 / 55. 3.100

libavfilter 3. 87.100 / 3. 87.100

libswscale 2. 5.100 / 2. 5.100

libswresample 0. 17.103 / 0. 17.103

libpostproc 52. 3.100 / 52. 3.100

Input #0, avi, from '41.avi':

Duration: 00:00:01.20, start: 0.000000, bitrate: 16930 kb/s

Stream #0:0: Video: rawvideo, pal8, 351x240, 25 tbr, 25 tbn, 25 tbc

Metadata:

title : F:\video\Journal\NLM\Suzie\41.avi


here is the code, but I think nothing different


#include <iostream>
#include <string>
#include <sstream>
#include "opencv/highgui.h"

using namespace std ;
using namespace cv ;

int main()
{
    string fname = "/your/path/to/41.avi" ;
    string savep = "/your/path/to/save/frames/" ;

    VideoCapture video(fname) ;
    Mat frame ;

    if( !video.isOpened() ) {
        cout << "Open file failed" << endl ;
        return false ;
    }

   int c = 0 ;

   for(;;++c)
   {
       if( video.read( frame ) == false )
           break ;

       stringstream ss ;
       ss << savep << c << ".jpg" ;

       imwrite( ss.str() , frame ) ;
   }
   cout << c << " frame dumped" << endl ;
   return true ;
}
2013-09-25 10:11:07 -0600 commented question OpenCV windows xp install problems "opencv.hpp:no such file or directory"

1) try #include "include/opencv2/opencv.hpp" instead of <include/opencv2/opencv.hpp>

2) try to put the path setting to the PATH, and remember to restart the XP to activate the setting.

2013-09-25 09:58:31 -0600 commented question Unable to build opencv on the raspberry pi running raspbian

why there are "...gpu..." in the compiling message when you using "Raspberry Pi"

Have you selected any "BUILD_opencv_gpu", "with CUDA", "with CUFFT", or "with CUBLAS"?

2013-09-25 09:38:07 -0600 received badge  Editor (source)
2013-09-25 09:36:26 -0600 answered a question I can't install OpenCV on Windows 7, using MinGW and CMake.

1) Yes, if there is any failure in CMake, you will fail while compiling.

Do not ignore any error or even warning in CMake by keep pressing "configure".

Fix the error or warning in CMake configure log.

When you selecting "with XXX", make sure you have XXX on your computer or it will be build by OpenCV.

2) Put more information about the failure in CMake or compiling, so people can give you more specific suggestion.

3) You can install Qt5 before configuring OpenCV 2.4.6 . Then in CMake, selecting "with Qt".

Use "Grouped" and "Advanced" well to check if there is any failure about finding Qt.