Ask Your Question

cartycrabber's profile - activity

2017-06-22 20:53:52 -0600 asked a question Best methods for detecting trees in aerial images?

I'm working on a project to count the number of trees in an aerial image. I've looked at different object detection techniques in OpenCV (haar cascades, HOG) but I feel like I don't have a very good grasp one what situations to use the different techniques in. I'm thinking that I'm probably going to implement a few techniques and compare them, but which techniques should I be looking at and why?

2017-04-10 16:51:28 -0600 commented answer SVM training image coming out full white?

Worked exactly like you said, thanks!

2017-04-10 16:50:12 -0600 received badge  Scholar (source)
2017-04-10 12:46:21 -0600 asked a question SVM training image coming out full white?

I'm attempting to create an SVM classifier that trains from images in a couple folders. I'm able to get the images fine, but when I followed another post to create the training image, I put an imshow at the end to see what it looked like and it is just a fully white image. Is that normal, or have I done something wrong?

Here is my code:

//List of files in each training directory
std::vector<cv::String> ltvFiles;
std::vector<cv::String> mtvFiles;
std::vector<cv::String> htvFiles;

//Get the training image file names
cv::glob("data/training/ltv", ltvFiles);
cv::glob("data/training/mtv", mtvFiles);
cv::glob("data/training/htv", htvFiles);

//Number of files across all directories
int numFiles = ltvFiles.size() + mtvFiles.size() + htvFiles.size();

//Look at one image to get the area (assuming all the other images are the same size)
cv::Mat sample = cv::imread(ltvFiles[0]);
int imgArea = sample.rows * sample.cols;
sample.release();

//Create the training matrix with numFiles rows and imgArea columns
cv::Mat trainingMat(numFiles, imgArea, CV_32FC1);

cv::Mat img;
int col = 0;
//go through LTV images first
for (int image = 0; image < ltvFiles.size(); image++) {
    //Open the next image
    img = cv::imread(ltvFiles[image], 0);
    //Start in the first column
    col = 0;

    //Iterate through each pixel in the opened image and place it in the next location in the current row
    for (int y = 0; y < img.rows; y++) {
        for (int x = 0; x < img.cols; x++) {
            trainingMat.at<float>(image, col++) = img.at<uchar>(y, x);
        }
    }
}

//Skipping code for MTV and HTV

//Show the result
cv::imshow("Training image", trainingMat);

I'm wondering if it has something to do with this line in the bottom for loop

trainingMat.at<float>(image, col++) = img.at<uchar>(y, x);

Is the uchar to float a problem?