Ask Your Question

Nenad Bulatovic's profile - activity

2020-08-27 17:40:00 -0600 received badge  Notable Question (source)
2018-09-19 08:21:39 -0600 received badge  Famous Question (source)
2018-01-15 01:26:39 -0600 received badge  Popular Question (source)
2017-03-07 19:03:01 -0600 received badge  Notable Question (source)
2015-06-23 00:24:57 -0600 received badge  Notable Question (source)
2015-03-31 06:00:03 -0600 received badge  Popular Question (source)
2014-09-12 05:32:51 -0600 received badge  Popular Question (source)
2013-08-27 10:05:44 -0600 commented answer cvFlip function

@StevenPuttemans Thank you for advice. I will follow it.

2013-08-27 09:37:14 -0600 received badge  Student (source)
2013-08-27 03:02:34 -0600 commented answer cvFlip function

Right, I looked at: void flip(InputArray src, OutputArray dst, int flipCode) and totally neglected void cvFlip(const CvArr* src, CvArr* dst=NULL, int flip_mode=0 ), because I am used to OpenCV2. Thanks.

2013-08-27 01:48:05 -0600 asked a question cvFlip function

I found this in some code that I am adjusting for my needs:

 cvFlip ( img, NULL, 1 );

I don't see any logic behind it. Am I missing something?

EDIT: NULL confused me.

2013-08-18 08:06:00 -0600 asked a question asmlibrary and MinGW

I am trying to compile code which uses asmlibrary (by Yao Wei) with MinGW (gcc/g++ 4.7.2), without success. I can compile same library (asmlibrary.dll) with MVSC, and author also published three files (cygasmlibrary-4.dll, libasmlibrary.a, libasmlibrary.dll.a) which supposedly should work with gcc. When I try to comppile code which uses asmlibrary, I got this error:

13:06:05 **** Rebuild of configuration Release for project AsmLibrarySDK_FIT ****
Info: Internal Builder is used for build
g++ "-IC:\\OpenCV246PC\\build\\include" -O3 -Wall -c -fmessage-length=0 -o demo_fit.o "..\\demo_fit.cpp" 
g++ "-IC:\\OpenCV246PC\\build\\include" -O3 -Wall -c -fmessage-length=0 -o video_camera.o "..\\video_camera.cpp" 
g++ "-IC:\\OpenCV246PC\\build\\include" -O3 -Wall -c -fmessage-length=0 -o vjfacedetect.o "..\\vjfacedetect.cpp" 
..\vjfacedetect.cpp: In function ‘bool detect_all_faces(asm_shape**, int&, const IplImage*)’:
..\vjfacedetect.cpp:85:11: warning: variable ‘pt1’ set but not used [-Wunused-but-set-variable]
..\vjfacedetect.cpp:85:16: warning: variable ‘pt2’ set but not used [-Wunused-but-set-variable]
g++ "-LC:\\OpenCV246MinGW\\x86\\lib" "-LC:\\asmlibraryFaceXpress" -o AsmLibrarySDK_FIT.exe vjfacedetect.o video_camera.o demo_fit.o -lopencv_calib3d246 -lopencv_contrib246 -lopencv_core246 -lopencv_features2d246 -lopencv_flann246 -lopencv_gpu246 -lopencv_highgui246 -lopencv_imgproc246 -lopencv_legacy246 -lopencv_ml246 -lopencv_nonfree246 -lopencv_objdetect246 -lopencv_photo246 -lopencv_stitching246 -lopencv_video246 -lopencv_videostab246 -lasmlibrary 
demo_fit.o:demo_fit.cpp:(.text.startup+0x4c9): undefined reference to `_imp___ZN10asmfitting12ASMSeqSearchER9asm_shapePK9_IplImageibi'
demo_fit.o:demo_fit.cpp:(.text.startup+0x638): undefined reference to `_imp__InitShapeFromDetBox'
demo_fit.o:demo_fit.cpp:(.text.startup+0x21c): undefined reference to `_imp__InitShapeFromDetBox'
demo_fit.o:demo_fit.cpp:(.text.startup+0x286): undefined reference to `_imp___ZN10asmfitting8Fitting2EP9asm_shapeiPK9_IplImagei'
demo_fit.o:demo_fit.cpp:(.text.startup+0x442): undefined reference to `_imp___ZN10asmfitting12ASMSeqSearchER9asm_shapePK9_IplImageibi'
demo_fit.o:demo_fit.cpp:(.text.startup+0x58c): undefined reference to `_imp__InitShapeFromDetBox'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: demo_fit.o: bad reloc address 0x0 in section `.ctors'
c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status

I asked author about this and he replied to me as follows:

just link like libasmlibrary.a not -lasmlibrary

what I don't understand. Even if I try from command line, g++ won't accept:

C:\Users\Nenad\eclipseCDT\opencv2cookbook\AsmLibrarySDK_FIT\Debug>g++ "-LC:\OpenCV246MinGW\x86\lib" "-LC:\asmlibraryFaceXpress" -o AsmLibrarySDK_FIT.exe vjfacedetect.o video_camera.o demo_fit.o -l opencv_calib3d246 -lopencv_contrib246 -lopencv_core246 -lopencv_features2d246 -lopencv_flann246 -lopencv_gpu246 -lopencv_highgui246 -lopencv_imgproc246 -lopencv_legacy246 -lopencv_ml246 -lopencv_nonfr ee246 -lopencv_objdetect246 -lopencv_photo246 -lopencv_stitching246 -lopencv_video246 -lopencv_videostab246 libasmlibrary.a

(error is same as on top of post) if I try to put -libasmlibrary.a (the of course) I got: c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: cannot find -llibasmlibrary.a

libasmlibrary gives me g++: error: libasmlibrary: No such file or directory and so on...

As far as I know the only correct way to link this library would be to use -lasmlibrary but then it produces the error mentioned at the top.

BTW, even if I don't include that library at all, I got this error anyway.

Then I asked author again, and he replied to me:

Code like this g++ a.c -o test libasmlibrary.a -lopencv_library

And ... (more)

2013-08-13 11:17:32 -0600 commented answer error: taking address of temporary [-fpermissive]

Thank you. When I correct similar errors in whole project I will compile with functionality hopefully retained :)

2013-08-13 10:01:55 -0600 asked a question error: taking address of temporary [-fpermissive]

I have this code which I can compile successfully in MS VS 2010, but with eclipse CDT & MinGW (gcc 4.72) I have three errors:

..\find_classes.h:90:17: error: taking address of temporary [-fpermissive]
..\find_classes.h:94:51: error: invalid initialization of non-const reference of type ‘cv::Mat&’ from an rvalue of type ‘cv::Mat’
..\find_classes.h:82:8: error: in passing argument 2 of ‘double get_distance(cv::Mat&, cv::Mat&)’

Anyone willing me to explain what is actual problem and how to fix this?

Code is here:

#ifndef _FIND_CLASSES_H_
#define _FIND_CLASSES_H_
#include "asmlibrary.h"
#include <string>
#include <fstream>

using namespace std;

const int N_FEATURES = 7;
int N_EXPRESSIONS;
int N_SAMPLES;
int N_POINTS;
char** EXP_NAMES;
int *classLabelArray;
double *classPointArray;
cv::Mat classLabels;
cv::Mat classPoints;
//cv::Mat classDistances;
cv::Mat diff;


void read_config_from_file(string filename){
    // ifstream file(filename, ios::in); // NMB
    ifstream file(filename.c_str(), ios::in);
    if(!file.is_open()){
        cout << "error opening file: " << filename << endl;
        exit(1);
    }

    file >> N_EXPRESSIONS >> N_SAMPLES;
    N_POINTS = N_EXPRESSIONS * N_SAMPLES;

    EXP_NAMES = new char*[N_EXPRESSIONS];   //read expression names from file
    for(int i=0 ; i<N_EXPRESSIONS ; i++){
        EXP_NAMES[i] = new char[11];
        file >> EXP_NAMES[i];
    }

    classLabelArray = new int[N_POINTS];    //create classLabelArray (independent from file)
    for(int i=0 ; i<N_POINTS ; i++){
        classLabelArray[i] = i/N_SAMPLES;
    }

    classPointArray = new double[N_POINTS*N_FEATURES];  //read feature values for each class from file
    for(int i=0 ; i<N_POINTS*N_FEATURES ; i++){
        file >> classPointArray[i];
    }

    file.close();

    classLabels = cv::Mat(1, N_POINTS, CV_32SC1, classLabelArray);
    classPoints = cv::Mat(N_POINTS, N_FEATURES, CV_64FC1, classPointArray);
    //classDistances = cv::Mat(N_POINTS, 1, CV_64FC1);
    diff = cv::Mat(1, N_FEATURES, CV_64FC1);
}

void config(string filename, int n_expressions, int n_samples, string *exp_names){
    // ofstream file(filename, ios::out);
    ofstream file(filename.c_str(), ios::in);
    if(!file.is_open()){
        cout << "error opening file: " << filename << endl;
        exit(1);
    }

    N_EXPRESSIONS = n_expressions;
    N_SAMPLES = n_samples;
    file << N_EXPRESSIONS << endl << N_SAMPLES << endl;
    cout << N_EXPRESSIONS << endl << N_SAMPLES << endl;
    N_POINTS = N_EXPRESSIONS * N_SAMPLES;

    EXP_NAMES = new char*[N_EXPRESSIONS];
    for(int i=0 ; i<N_EXPRESSIONS ; i++){
        cout<< exp_names[i] << endl;

        EXP_NAMES[i] = strdup(exp_names[i].c_str());
        file << EXP_NAMES[i] << endl;
    }

    file.close();
}

double get_distance(cv::Mat& p32, cv::Mat& p64) { // error: in passing argument 2 of ‘double get_distance(cv::Mat&, cv::Mat&)’
    for(int i=0; i<N_FEATURES; i++)
        diff.at<double>(0,i) = p32.at<float>(0,i) - p64.at<double>(0,i);
    return cv::norm(diff);
}

cv::Mat get_class_weights(cv::Mat instance) {
    cv::Mat weights = cv::Mat(1,N_EXPRESSIONS, CV_64FC1);
    cvZero(&(CvMat)weights); // <-- error: taking address of temporary [-fpermissive]
    double dist;

    for(int i = 0; i<N_POINTS; i++) {
        dist = get_distance(instance, classPoints.row(i)); // error: invalid initialization of non-const reference of type ‘cv::Mat&’ from an rvalue of type ‘cv::Mat’
        // classDistances.at<double>(i,0) = dist;
        // printf("%d ", classLabels.at<int>(0,i));
        weights.at<double>(0, classLabels.at<int>(0,i)) += dist;
        //printf("%.2f ",dist);
    }
    //cout <<endl;
    // printf("%lf %lf\n", weights.at<double>(0,0), weights.at<double>(0,1));

    for(int i = 0; i < N_EXPRESSIONS; i++)
        weights.at<double>(0,i) = exp(-weights.at<double>(0,i));

    double sum = cv ...
(more)
2013-08-13 08:28:53 -0600 commented question Names of new libraries

@StevenPuttemans Sorry, I wrote INCLUDE instead of LINK. The problem occured with LINKER. Those 4 libraries done the trick: opencv_imgproc246d.lib opencv_core246d.lib opencv_highgui246d.lib opencv_objdetect246d.lib

2013-08-13 08:17:42 -0600 commented question Names of new libraries

@berak those 4 libraries done the trick: opencv_imgproc246d.lib opencv_core246d.lib opencv_highgui246d.lib opencv_objdetect246d.lib

2013-08-13 08:15:51 -0600 commented answer Names of new libraries

I have working setup of OpenCV 2.4.6 on windos machine (I compiled my own libraries with CMake). Now, I've got some example where guy who sent it to me is using precompiled libraries, and those two libraries in question: cv210.lib cxcore210.lib. I compile my projects within IDE (Eclipse CDT or VS2010). I am not aware that I can or I should compile projects with CMake? Can you point me to tutorial how to do it?

2013-08-13 08:08:15 -0600 commented question Names of new libraries

@StevenPuttemans I know that, what I asked is what exactly NEW libraries are direct replacement for OLD libraries, specifically cv210.lib and cxcore210.lib

2013-08-12 12:42:58 -0600 commented question Names of new libraries

No, it won't do the trick.

In VS2010, Project properties, Configuration Properties, Linker, Input, Additional decencies I have to name all of the libraries that are used.

2013-08-12 10:40:57 -0600 asked a question Names of new libraries

I have to compile an old project, and libraries that I have to LINK (among others) are:

cv210.lib
cxcore210.lib

What are names for those libraries in new OpenCV 2.4.6 ?

2013-08-05 14:02:00 -0600 commented question call of overloaded ‘Point_(cv::Point2f&)’ is ambiguous

Error was corrected as: cv::circle(result, cv::Point2f(center), static_cast<int>(radius), cv::Scalar(0), 2); so cv::Point(center) become this cv::Point2f(center). The problem is likely that I was making a cv::Point from a cv::Point2f. cv::Point is declared as typedef Point2i Point;, meaning that it's equivalent to a cv::Point2i. I was trying to make a cv::Point2i from a cv::Point2f, which is incorrect.

2013-08-05 13:01:07 -0600 asked a question call of overloaded ‘Point_(cv::Point2f&)’ is ambiguous

I am working on some example code for OpenCV2 & C++ and I got stuck. Compiler (MinGW, g++ 4.7.2 on Win7) says that call of overloaded ‘Point_(cv::Point2f&)’ is ambiguous but I can't find exatcly what is wrong. Here is error:

19:53:36 **** Incremental Build of configuration Debug for project Blobs ****
Info: Internal Builder is used for build
g++ "-IC:\\OpenCV246PC\\build\\include" -O0 -g3 -Wall -c -fmessage-length=0 -o blobs.o "..\\blobs.cpp" 
..\blobs.cpp: In function ‘int main()’:
..\blobs.cpp:48:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
..\blobs.cpp:48:43: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
..\blobs.cpp:84:37: error: call of overloaded ‘Point_(cv::Point2f&)’ is ambiguous
..\blobs.cpp:84:37: note: candidates are:
In file included from ..\blobs.cpp:3:0:
C:\OpenCV246PC\build\include/opencv2/core/core.hpp:740:5: note: cv::Point_<_Tp>::Point_(const CvPoint2D32f&) [with _Tp = int; CvPoint2D32f = CvPoint2D32f]
C:\OpenCV246PC\build\include/opencv2/core/core.hpp:739:5: note: cv::Point_<_Tp>::Point_(const CvPoint&) [with _Tp = int; CvPoint = CvPoint]
C:\OpenCV246PC\build\include/opencv2/core/core.hpp:738:5: note: cv::Point_<_Tp>::Point_(const cv::Point_<_Tp>&) [with _Tp = int; cv::Point_<_Tp> = cv::Point_<int>]

And here is the code:

#include <iostream>
#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

int main()
{
    // Read input binary image
    cv::Mat image = cv::imread("binaryGroup.bmp", 0);
    if (!image.data)
        return 0;

    cv::namedWindow("Binary Image");
    cv::imshow("Binary Image", image);

    // Get the contours of the connected components
    std::vector<std::vector<cv::Point> > contours;
    cv::findContours(image, contours, // a vector of contours
            CV_RETR_EXTERNAL, // retrieve the external contours
            CV_CHAIN_APPROX_NONE); // retrieve all pixels of each contours

    // Print contours' length
    std::cout << "Contours: " << contours.size() << std::endl;
    std::vector<std::vector<cv::Point> >::const_iterator itContours = contours.begin();
    for (; itContours != contours.end(); ++itContours)
    {

        std::cout << "Size: " << itContours->size() << std::endl;
    }

    // draw black contours on white image
    cv::Mat result(image.size(), CV_8U, cv::Scalar(255));
    cv::drawContours(result, contours, -1, // draw all contours
            cv::Scalar(0), // in black
            2); // with a thickness of 2

    cv::namedWindow("Contours");
    cv::imshow("Contours", result);

    // Eliminate too short or too long contours
    int cmin = 100;  // minimum contour length
    int cmax = 1000; // maximum contour length
    std::vector<std::vector<cv::Point> >::iterator itc = contours.begin();
    while (itc != contours.end())
    {

        if (itc->size() < cmin || itc->size() > cmax)
            itc = contours.erase(itc);
        else
            ++itc;
    }

    // draw contours on the original image
    cv::Mat original = cv::imread("group.jpg");
    cv::drawContours(original, contours, -1, // draw all contours
            cv::Scalar(255, 255, 255), // in white
            2); // with a thickness of 2

    cv::namedWindow("Contours on Animals");
    cv::imshow("Contours on Animals", original);

    // Let's now draw black contours on white image
    result.setTo(cv::Scalar(255));
    cv::drawContours(result, contours, -1, // draw all contours
            cv::Scalar(0), // in black
            1); // with a thickness of 1
    image = cv::imread("binaryGroup.bmp", 0);

    // testing ...
(more)
2013-07-07 03:46:26 -0600 answered a question OpenVC 2.4.5, eclipse CDT Juno, MinGW error 0xc0000005

Finally I resolved it with compiling my own binaries as described here

2013-07-06 06:29:11 -0600 commented answer Capture one resolution from camera but display another

This will do the trick: capture.set(CV_CAP_PROP_FRAME_WIDTH, 640); (At least in OpenCV 2.4.5)

2013-07-06 06:25:51 -0600 commented answer Capture one resolution from camera but display another

Unfortunately VideoCapture::set won't work either. Are you using OpenCV2.4.5 as well?

2013-07-06 05:58:08 -0600 marked best answer Capture one resolution from camera but display another

How can I get one resolution feed from camera in OpenCV (640x320) but cut it into half and display only one half of the frame (320x240). So not to scale down, but to actually crop. Should I use IplImage or Mat? I am quite new to OpenCV and a bit confused :)

I am using this quite standard code to get 640x480 input resolution and I made some changes to crop resolution to 320x480. Is it good or should I use Mat instead of IplImage?

// CameraFeed01.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"

using namespace std;
char key;
int main()
{
    cvNamedWindow("Camera_Output", 1);    //Create window

    CvCapture* capture = cvCaptureFromCAM(1);  //Capture using camera 1 connected to system
    cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH, 640 );
    cvSetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT, 480 );

    while(1){ //Create loop for live streaming

        IplImage* framein = cvQueryFrame(capture); //Create image frames from capture

        /* sets the Region of Interest  - rectangle area has to be __INSIDE__ the image */
        cvSetImageROI(framein, cvRect(0, 0, 320, 240));

        /* create destination image  - cvGetSize will return the width and the height of ROI */
        IplImage *frameout = cvCreateImage(cvGetSize(framein),  framein->depth, framein->nChannels);

        /* copy subimage */
        cvCopy(framein, frameout, NULL);

        /* always reset the Region of Interest */
        cvResetImageROI(framein);

        cvShowImage("Camera_Output", frameout);   //Show image frames on created window

        key = cvWaitKey(10);     //Capture Keyboard stroke
        if (char(key) == 27){
            break;      //ESC key loop will break.
        }
    }

    cvReleaseCapture(&capture); //Release capture.
    cvDestroyWindow("Camera_Output"); //Destroy Window
    return 0;
}
2013-07-06 05:58:04 -0600 commented answer Capture one resolution from camera but display another

Why I am not receiving on my email notifications that someone has replied to my question? Is there some specific setting on this forum?