Ask Your Question

MalcolmMaya's profile - activity

2020-10-21 13:15:38 -0600 received badge  Notable Question (source)
2018-12-17 10:01:45 -0600 received badge  Popular Question (source)
2017-09-26 07:25:04 -0600 received badge  Student (source)
2015-04-14 04:01:17 -0600 commented answer Position of a Roi in a mat

locateROI is the function I missed in the docs. Thanks a lot

2015-04-14 04:00:31 -0600 received badge  Scholar (source)
2015-04-14 04:00:29 -0600 received badge  Supporter (source)
2015-04-13 16:28:37 -0600 asked a question Position of a Roi in a mat

Is it possible to know the position of a ROI made from a Mat if you pass both of them as argument of a function ?

2015-04-13 15:21:42 -0600 received badge  Enthusiast
2015-04-07 18:04:20 -0600 received badge  Editor (source)
2015-04-07 17:54:05 -0600 asked a question Cmake can't find OpenCV

I was using OpenCv from the repo under Fedora 21. Since I wanted to use the latest version, I downloaded the git version and followed the install instruction here. However when I try to compile my old project which worked fine with the repo it doesn't seem to work anymore :

[malcolm@localhost build]$ make
Scanning dependencies of target mapmakerv3_automoc
[  7%] Automatic moc for target mapmakerv3
Generating MapMakerv3.moc
/mnt/bokkie/GoogleDrive/Work/AASS/TobotMaker/MapMakerGraphical/MapMakerv3/includes/Qtfiles/MapMakerv3.cpp:0: Note: No relevant classes found. No output generated.
Generating imageLabel.moc
/mnt/bokkie/GoogleDrive/Work/AASS/TobotMaker/MapMakerGraphical/MapMakerv3/includes/Qtfiles/imageLabel.cpp:105: Note: No relevant classes found. No output generated.
Generating moc_MapMakerv3.cpp
Generating moc_imageLabel.cpp
[  7%] Built target mapmakerv3_automoc
Scanning dependencies of target mapmakerv3
[ 14%] Building CXX object CMakeFiles/mapmakerv3.dir/includes/Qtfiles/MapMakerv3.cpp.o
In file included from /mnt/bokkie/GoogleDrive/Work/AASS/TobotMaker/MapMakerGraphical/MapMakerv3/includes/Qtfiles/MapMakerv3.h:18:0,
                 from /mnt/bokkie/GoogleDrive/Work/AASS/TobotMaker/MapMakerGraphical/MapMakerv3/includes/Qtfiles/MapMakerv3.cpp:1:
/mnt/bokkie/GoogleDrive/Work/AASS/TobotMaker/MapMakerGraphical/MapMakerv3/includes/Qtfiles/imageLabel.h:16:16: fatal error: cv.h: No such file or directory
 #include <cv.h>
                ^
compilation terminated.

Here is my CMakeList.txt :

cmake_minimum_required(VERSION 2.6)
project(mapmakerv3)

set (MapMaker_VERSION_MAJOR 1)
set (MapMaker_VERSION_MINOR 0)

find_package(Qt4 REQUIRED)
find_package( OpenCV REQUIRED)

include_directories("${PROJECT_BINARY_DIR}" ${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} includes includes/Qtfiles includes/MapInterpretation/)

set(MapMakerv3_SRCS includes/Qtfiles/MapMakerv3.cpp main.cpp includes/Qtfiles/imageLabel.cpp)

set(CMAKE_AUTOMOC TRUE)
add_executable(mapmakerv3 ${MapMakerv3_SRCS})
target_link_libraries(mapmakerv3 ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${OpenCV_LIBS})

add_executable(test_map_import Test/mapimport.cpp)
target_link_libraries(test_map_import ${OpenCV_LIBS} -lboost_unit_test_framework )

add_executable(test_voronoi Test/Voronoi_test.cpp)
target_link_libraries(test_voronoi ${OpenCV_LIBS} -lboost_unit_test_framework )

add_executable(test_delaunay Test/test_delaunay.cpp)
target_link_libraries(test_delaunay ${OpenCV_LIBS} -lboost_unit_test_framework )


install(TARGETS mapmakerv3 RUNTIME DESTINATION bin)

add_subdirectory(includes/MapInterpretation)
add_subdirectory(includes/Qtfiles)

Appears I need to change all my include with "cv.h" to "opencv/cv.h". But it means my program will not work with someone who installed it from the repo. Why is that ?

[EDIT] even better if someone knows how I can make CMake use a version that I would install locally =) !

2015-04-07 15:25:03 -0600 asked a question Voronoi lines

I'm trying to have an image with the voronoi line (the point on the image which are at an equal distance of at least to 0-value pixel). I know of distanceTransform and for now I'm using this to return either the distance Mat or the label. I've tried using line detector to find the line but, if I use the label, I don't have all the line, if I use the distances, the image gets rather messy.

Using delaunay here isn't really an option because I have only an image with lines and no points to give to Subdiv2D. Plus subdiv doesn't give me an image as a result.

Is there any "easy way" to get all those point at equal distance of 0-value pixel ? If I could not have to reimplement a Voronoi less efficient than the one implemented I'll be really glad.

Here is a (bad) image made under GIMP. If the red lines are the 0-values point, then the black line would be my Voronoi lines :

image description

Sorry for the very badly drawn drawing !

What I tried for now :

  • Doing distanceTransform and then
    • Using Laplace/Sobel to get the lines directly on the Vronoi diagram
    • Using Laplace/Sobel on the label from CCOMP. That wasn't to bad but I missed some line. Especially, when There is a square (like in the figure) all the line are considered as 1element and I have no lines anymore.
  • Using Delaunay.
  • Calculating local maximum value . That gave quite good results but the lines are often disconnected.

image description

For exemple, here are my results with Laplace and Sobel using the label. The Laplace one here is perfect because non of the lines are connected. If I were to put a "dead-end" (connect the two line on top for example), my top line would disappear. And I don't want that :)

Thanks !

2015-04-07 15:09:41 -0600 commented question iterate through a matrice, int to uchar problem

Arf, silly me, you're right ! Thanks a lot =)

2015-04-07 13:13:28 -0600 asked a question iterate through a matrice, int to uchar problem

I'm trying to modify in a for a loop a Mat. I'm following this article. However the following code does not work :

cv::Mat tmp(20, 20, CV_32F, cv::Scalar(0,0,0));

cv::MatIterator_<uchar> new_mat= tmp.begin<uchar>();
for( int i = 0; i< (tmp.size().width) ;i++){
    for(int j= 0;j< tmp.size().height;j++){

    (*new_mat) = 1;
    std::cout << (float) (*new_mat) << ", ";
    new_mat++;
    }
std::cout <<std::endl;
}
std::cout << std::endl << std::endl;

std::cout << tmp << std::endl;

std::string win = "Local Maxima";
cv::imshow(win, tmp);

Printing (float) (*new_mat) give a Matrix of 1 as explected but tmp if full of 1.4012985e-45 values and I can't seem to understand why. My guess is that it as to do with the way I'm assigning the value but I can't grasp the real problem here.

Any help is appreciated.

2015-04-07 06:25:36 -0600 commented question Using Sobel on label's of DistanceTransform

You should add your comment as an answer so I can accept it =)

2015-04-07 04:49:11 -0600 commented question Using Sobel on label's of DistanceTransform

Thanks it solved my problem. But maybe you meant CV_32F ;)

2015-04-06 22:46:26 -0600 asked a question Using Sobel on label's of DistanceTransform

I'm trying to use Sobel on the Distance Transform label as a way to only have Voronoi lines in the resulting map.

This is my code so far :

cv::Mat mat_test(heigh,width, CV_8UC3, cv::Scalar(0,0,0));
cv::circle(mat_test, cv::Point2d(0, 0), 1, cv::Scalar(255,255,255), -1);
cv::circle(mat_test, cv::Point2d(9, 9), 1, cv::Scalar(255,255,255), -1);
cv::circle(mat_test, cv::Point2d(0, 9), 1, cv::Scalar(255,255,255), -1);
cv::Mat result_ccomp;
cv::Mat other_result;
cv::Mat label;
cv::Mat label_pixel;

cv::cvtColor(mat_test, mat_test, CV_RGB2GRAY);
cv::threshold(mat_test, mat_test, 10, 255, CV_THRESH_BINARY_INV);
cv::Mat dist;
cv::distanceTransform(mat_test,result_ccomp, label, CV_DIST_L2, CV_DIST_MASK_PRECISE, CV_DIST_LABEL_CCOMP);
cv::distanceTransform(mat_test, other_result, label_pixel, CV_DIST_L2, CV_DIST_MASK_PRECISE, CV_DIST_LABEL_PIXEL);
cv::normalize(result_ccomp, result_ccomp, 0, 1., cv::NORM_MINMAX);
cv::normalize(other_result, other_result, 0, 100, cv::NORM_MINMAX);

cv::Mat sobelX;
cv::Mat sobelY;
cv::Mat sobel;
//int ddepth = CV_16S;
int scale = 1;
int delta = 0;
/// Gradient X

std::cout << "type : " << sobelX.type() << " type label : "<<label.type()<<std::endl;
cv::Sobel( label, sobelX, -1, 1, 0, 3, scale, delta, cv::BORDER_DEFAULT );

But when I try to run this little program I hit this error :

OpenCV Error: The function/feature is not implemented (Unsupported combination of source format (=4), and buffer format (=5)) in getLinearRowFilter, file /builddir/build/BUILD/opencv-2.4.9/modules/imgproc/src/filter.cpp, line 2857
unknown location(0): fatal error in "trying": std::exception: /builddir/build/BUILD/opencv-2.4.9/modules/imgproc/src/filter.cpp:2857: error: (-213) Unsupported combination of source format (=4), and buffer format (=5) in function getLinearRowFilter

I don't really understand what it means and how I got this error... Any help is appreciated.