Ask Your Question

openman's profile - activity

2020-02-05 08:49:39 -0600 received badge  Popular Question (source)
2015-12-03 08:02:10 -0600 asked a question Find Centroid Of Objects In Binary Image

I would like to find centroid points for each objects in a binary image. How can I do?

2015-07-21 03:31:41 -0600 received badge  Enthusiast
2015-07-10 03:35:46 -0600 commented question Cannot Import External Library

Unfortunately, nothing changed.

2015-07-10 03:19:09 -0600 received badge  Editor (source)
2015-07-10 03:17:58 -0600 asked a question Cannot Import External Library

I kept track of the instructions in that link. I downloaded the repository. Then, I applied those commands: cd C:\OpenCV3.0.0\opencv\build cmake -DOPENCV_EXTRA_MODULES_PATH=C:\opencv_contrib-master\modules C:\OpenCV3.0.0\opencv\sources It creates an CMakeError.txt file including lots of errors.

Related parts:

Build FAILED.

"C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_93c95.vcxproj" (default target) (1) ->

(Link target) -> 

  CheckFunctionExists.obj : error LNK2019: unresolved external symbol _fseeko referenced in function _main [C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_93c95.vcxproj]

  C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\Debug\cmTC_93c95.exe : fatal error LNK1120: 1 unresolved externals [C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_93c95.vcxproj]

    0 Warning(s)

    2 Error(s)


Build FAILED.

"C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_6e125.vcxproj" (default target) (1) ->

(ClCompile target) -> 

  C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\CheckIncludeFile.c(1): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory [C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_6e125.vcxproj]

    0 Warning(s)

    1 Error(s)


Build FAILED.

"C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_3a774.vcxproj" (default target) (1) ->

(ClCompile target) -> 

  C:\OpenCV3.0.0\opencv\build\CMakeFiles\CheckTypeSize\OFF64_T.c(19): error C2065: 'off64_t' : undeclared identifier [C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_3a774.vcxproj]

  C:\OpenCV3.0.0\opencv\build\CMakeFiles\CheckTypeSize\OFF64_T.c(20): error C2065: 'off64_t' : undeclared identifier [C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_3a774.vcxproj]

  C:\OpenCV3.0.0\opencv\build\CMakeFiles\CheckTypeSize\OFF64_T.c(21): error C2065: 'off64_t' : undeclared identifier [C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_3a774.vcxproj]

  C:\OpenCV3.0.0\opencv\build\CMakeFiles\CheckTypeSize\OFF64_T.c(22): error C2065: 'off64_t' : undeclared identifier [C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_3a774.vcxproj]

  C:\OpenCV3.0.0\opencv\build\CMakeFiles\CheckTypeSize\OFF64_T.c(23): error C2065: 'off64_t' : undeclared identifier [C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_3a774.vcxproj]

    0 Warning(s)

    5 Error(s)



Build FAILED.

"C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_0f669.vcxproj" (default target) (1) ->

(Link target) -> 

  CheckFunctionExists.obj : error LNK2019: unresolved external symbol _jbg_newlen referenced in function _main [C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_0f669.vcxproj]

  C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\Debug\cmTC_0f669.exe : fatal error LNK1120: 1 unresolved externals [C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_0f669.vcxproj]

    0 Warning(s)

    2 Error(s)



Build FAILED.

"C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_2f0ec.vcxproj" (default target) (1) ->

(Link target) -> 

  CheckFunctionExists.obj : error LNK2019: unresolved external symbol _mmap referenced in function _main [C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_2f0ec.vcxproj]

  C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\Debug\cmTC_2f0ec.exe : fatal error LNK1120: 1 unresolved externals [C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_2f0ec.vcxproj]

    0 Warning(s)

    2 Error(s)



Build FAILED.

"C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp\cmTC_4b3e8.vcxproj" (default target) (1) ->

(ClCompile target) -> 

  C:\OpenCV3.0.0\opencv\build\CMakeFiles\CMakeTmp ...
(more)
2015-07-10 02:29:11 -0600 commented question How To Import External Library To OpenCV

I kept track of the instructions in that link. I applied those commands: cd C:\OpenCV3.0.0\opencv\build cmake -DOPENCV_EXTRA_MODULES_PATH=C:\opencv_contrib-master\modules C:\OpenCV3.0.0\opencv\sources It creates an CMakeError.txt file including lots of errors.

2015-07-09 10:25:09 -0600 asked a question How To Import External Library To OpenCV

I would like to extract features of images using opencv 3.0 with Visual Studio 2013.

My code:

#include <stdio.h>
#include <iostream>
#include "opencv2\core.hpp"
#include "opencv2\features2d.hpp"
#include <opencv2\xfeatures2d.hpp>
#include <opencv2\highgui.hpp>

using namespace cv;
using namespace cv::xfeatures2d;

void readme();

/** @function main */
int main(int argc, char** argv)
{
    if (argc != 3)
    {
        readme(); return -1;
    }

    Mat img_1 = imread(argv[1], IMREAD_GRAYSCALE);
    Mat img_2 = imread(argv[2], IMREAD_GRAYSCALE);

    if (!img_1.data || !img_2.data)
    {
        std::cout << " --(!) Error reading images " << std::endl; return -1;
    }

    //-- Step 1: Detect the keypoints using SURF Detector
    int minHessian = 400;

    Ptr<SURF> detector = SURF::create(minHessian);

    std::vector<KeyPoint> keypoints_1, keypoints_2;

    detector->detect(img_1, keypoints_1);
    detector->detect(img_2, keypoints_2);

    //-- Draw keypoints
    Mat img_keypoints_1; Mat img_keypoints_2;

    drawKeypoints(img_1, keypoints_1, img_keypoints_1, Scalar::all(-1), DrawMatchesFlags::DEFAULT);
    drawKeypoints(img_2, keypoints_2, img_keypoints_2, Scalar::all(-1), DrawMatchesFlags::DEFAULT);

    //-- Show detected (drawn) keypoints
    imshow("Keypoints 1", img_keypoints_1);
    imshow("Keypoints 2", img_keypoints_2);

    waitKey(0);

    return 0;
}

/** @function readme */
void readme()
{
    std::cout << " Usage: ./SURF_detector <img1> <img2>" << std::endl;
}

Error:

Cannot open include file: 'opencv2\xfeatures2d.hpp': No such file or directory

In C:\OpenCV3.0.0\opencv\build\include\opencv2

directory, there is no xfeatures2d.hpp file. Thus, I should import this library externally. How to fix it?

2015-07-08 09:03:29 -0600 commented question SVM Training Data Error

There is no problem :)

2015-07-08 05:10:12 -0600 commented question SVM Training Data Error

Thanks a lot. You are right.

2015-07-08 04:19:34 -0600 asked a question SVM Training Data Error

I would like to learn svm implementation by using opencv 3.00 library in C++ and Visual Studio 2013. My code:

#include<stdio.h>
#include<math.h>
#include<opencv\cv.h>
#include<opencv\highgui.h>
#include<opencv2\objdetect\objdetect.hpp>
#include<opencv2\highgui\highgui.hpp>
#include<opencv2\imgproc\imgproc.hpp>
#include<vector>
#include <windows.h>
#include <atlstr.h>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <opencv2\imgproc\imgproc.hpp>
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv\cvaux.hpp>

using namespace cv;
using namespace std;

#include <opencv2\ml.hpp>

using namespace cv;

int main()
{
    // Data for visual representation
    int width = 512, height = 512;
    Mat image = Mat::zeros(height, width, CV_8UC3);

    // Set up training data
    float labels[4] = { 1.0, -1.0, -1.0, -1.0 };
    Mat labelsMat(4, 1, CV_32FC1, labels);

    float trainingData[4][2] = { { 501, 10 }, { 255, 10 }, { 501, 255 }, { 10, 501 } };
    Mat trainingDataMat(4, 2, CV_32FC1, trainingData);

    // Set up SVM's parameters

    Ptr<ml::SVM> svm = ml::SVM::create();
    // edit: the params struct got removed,
    // we use setter/getter now:
    svm->setType(ml::SVM::C_SVC);
    svm->setKernel(ml::SVM::LINEAR);
    svm->setGamma(3);

    svm->train(trainingDataMat, ml::ROW_SAMPLE, labelsMat);

    Mat res;   // output


    Vec3b green(0, 255, 0), blue(255, 0, 0);
    // Show the decision regions given by the SVM
    for (int i = 0; i < image.rows; ++i)
        for (int j = 0; j < image.cols; ++j)
        {
        Mat sampleMat = (Mat_<float>(1, 2) << j, i);
        float response = svm->predict(sampleMat, res);

        if (response == 1)
            image.at<Vec3b>(i, j) = green;
        else if (response == -1)
            image.at<Vec3b>(i, j) = blue;
        }

    // Show the training data
    int thickness = -1;
    int lineType = 8;
    circle(image, Point(501, 10), 5, Scalar(0, 0, 0), thickness, lineType);
    circle(image, Point(255, 10), 5, Scalar(255, 255, 255), thickness, lineType);
    circle(image, Point(501, 255), 5, Scalar(255, 255, 255), thickness, lineType);
    circle(image, Point(10, 501), 5, Scalar(255, 255, 255), thickness, lineType);

    // Show support vectors
    thickness = 2;
    lineType = 8;
    Mat sv = svm->getSupportVectors();

    for (int i = 0; i < sv.rows; ++i)
    {
        const float* v = sv.ptr<float>(i);
        circle(image, Point((int)v[0], (int)v[1]), 6, Scalar(128, 128, 128), thickness, lineType);
    }

    imwrite("result.png", image);        // save the image

    imshow("SVM Simple Example", image); // show it to the user
    waitKey(0);

}

After running this code, I got that error:

OpenCV Error: Bad argument < in the case of classification problem the responses must be categorical; 
either specify varType when creating TrainData, or pass integer responses > in cv::ml::SVMImpl::train, 
file C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\ml\src\svm.cpp, line 1610

I debugged that code. The debugger stops at this line: svm->train(trainingDataMat, ml::ROW_SAMPLE, labelsMat); It says:

First-chance exception at 0x000007FEFDA5AAAD in train.exe: Microsoft C++ exception: cv::Exception at memory location 0x00000000001CEE50.
    Unhandled exception at 0x000007FEFDA5AAAD in train.exe: Microsoft C++ exception: cv::Exception at memory location 0x00000000001CEE50

Actually, what I understand is that the problem is related to the memory.