Ask Your Question
3

BaseRowFilter and BaseColumnFilter in opencv 3.x

asked 2016-03-02 12:25:09 -0600

theodore gravatar image

I have some old code which I would like to use/port:

template<typename T, typename ST> struct RowSum : public BaseRowFilter
{
    RowSum( int _ksize, int _anchor )
    {
        ksize = _ksize;
        anchor = _anchor;
    }

    void operator()(const uchar* src, uchar* dst, int width, int cn)
    {
        const T* S = (const T*)src;
        ST* D = (ST*)dst;
        int i = 0, k, ksz_cn = ksize*cn;

        width = (width - 1)*cn;
        for( k = 0; k < cn; k++, S++, D++ )
        {
            ST s = 0;
            for( i = 0; i < ksz_cn; i += cn )
                s += S[i];
            D[0] = s;
            for( i = 0; i < width; i += cn )
            {
                s += S[i + ksz_cn] - S[i];
                D[i+cn] = s;
            }
        }
    }
};

but apparently the BaseRowFilter and BaseColumnFilter classes are not public available anymore. Is there any way to bypass this restriction and make the above struct to work again as before?

I found a kind of similar question here by @wuling. So I do not know if @berak has any idea or if @wuling managed to find a workaround. Thanks.

edit retag flag offensive close merge delete

Comments

same problem with levenberg-marquardt code. My answer is copy code in your own code

LBerger gravatar imageLBerger ( 2016-03-02 15:42:43 -0600 )edit

I see, thanks Laurent ;-)

theodore gravatar imagetheodore ( 2016-03-03 04:31:46 -0600 )edit

Ok I copied the classes from here but now I am getting a strange error of:

CMakeFiles/weightedJointBilateralFilter.dir/guidedFilter.cpp.o: In function `createBoxFilterFFF(int, cv::Size_<int>, cv::Point_<int>, bool, int)':
guidedFilter.cpp:(.text+0xe3e): undefined reference to `BaseRowFilter::BaseRowFilter()'
guidedFilter.cpp:(.text+0xebd): undefined reference to `BaseColumnFilter::BaseColumnFilter()'
guidedFilter.cpp:(.text+0xf7f): undefined reference to `FilterEngine::FilterEngine(cv::Ptr<BaseFilter> const&, cv::Ptr<BaseRowFilter> const&, cv::Ptr<BaseColumnFilter> const&, int, int, int, int, int, cv::Scalar_<double> const&)'

any idea?

theodore gravatar imagetheodore ( 2016-03-03 09:35:35 -0600 )edit

I am sorry that it is the same question:)

wuling gravatar imagewuling ( 2016-03-03 10:14:56 -0600 )edit

I don't know how to use (still working and steerable pyramid) but I can compile this source code and link.

LBerger gravatar imageLBerger ( 2016-03-03 10:27:55 -0600 )edit

@wuling did you manage to make it work, in your case?

theodore gravatar imagetheodore ( 2016-03-03 10:44:35 -0600 )edit

@LBerger, Laurent I can compile your code without problem as well but if I try this code I get the error I mention above. Can you try my code and tell me if that is the case for you as well. Thanks in advance.

theodore gravatar imagetheodore ( 2016-03-03 11:01:26 -0600 )edit

only 5 link errors :

1>main.obj : error LNK2019: symbole externe non rÚsolu "public: __cdecl BaseRowFilter::BaseRowFilter(void)" (??0BaseRowFilter@@QEAA@XZ) rÚfÚrencÚ dans la fonction "public: __cdecl RowSum<float,float>::RowSum<float,float>(int,int)" (??0?$RowSum@MM@@QEAA@HH@Z)
1>main.obj : error LNK2019: symbole externe non rÚsolu "public: virtual __cdecl BaseRowFilter::~BaseRowFilter(void)" (??1BaseRowFilter@@UEAA@XZ) rÚfÚrencÚ dans la fonction "public: virtual __cdecl RowSum<float,float>::~RowSum<float,float>(void)" (??1?$RowSum@MM@@UEAA@XZ)
LBerger gravatar imageLBerger ( 2016-03-03 11:36:31 -0600 )edit

so you also have the problem...

theodore gravatar imagetheodore ( 2016-03-03 11:53:43 -0600 )edit
2

@theodore now it's ok for compile and link. I have to copy other function and I don't use namespace cv. Becarefull all functions are here but some are empty : you have to copy and replace mat with cv::mat...

LBerger gravatar imageLBerger ( 2016-03-03 12:38:26 -0600 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2016-09-19 03:53:33 -0600

hovnatan gravatar image

You can add CV_EXPORTS to class definitions in modules/imgproc/src/filterengine.hpp (e.g., class CV_EXPORTS BaseRowFilter) then compile/install openCV from scratch again. After that, copy the same filterengine.hpp to your project and include it. Everything should compile and link fine from that point. In the default case without CV_EXPORTS those classes are not made external in the output openCV shared libs.

edit flag offensive delete link more

Comments

It should work but as you wrote you have to change opencv source code

LBerger gravatar imageLBerger ( 2016-09-20 02:18:20 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-03-02 12:25:09 -0600

Seen: 2,176 times

Last updated: Sep 19 '16