Ask Your Question

gordano's profile - activity

2018-01-17 23:03:22 -0600 asked a question General edge detection question

General edge detection question This isn't necessarily specific to OpenCV, but I had the following question: I noticed

2018-01-08 21:38:02 -0600 commented answer trouble understanding pixel access

Update: I solved it: It seems the image needed to be reconverted to BGR to display correctly in imshow

2018-01-08 21:35:57 -0600 commented answer trouble understanding pixel access

Update: I solved it: I wasn't updating the saturation component.

2018-01-08 20:42:56 -0600 commented answer trouble understanding pixel access

Ok, I see the reference wasn't neccesary, your code works, I'm not sure what my problem was earlier since I tried nearly

2018-01-08 20:26:48 -0600 marked best answer trouble understanding pixel access

I am just getting into opencv and set up a demo just to get familiar.

I made a function to get and set pixel values, but it doesn't behave how I would expect. In this case I converted the Mat to RGB, but the only channel I can seem to effect is img.[1], which does alter the green component. Anything else, however doesn't work. I converted a mask Mat which is the output of an edge detector to RGB, and then also tried converting that to HSV and changing the img.[0] hue value, but that doesn't seem to do anything.

I am asking because even though my application is just experimenting, it seems like I am missing something about how to work with colors, and how values are contained in MAts.

For instance, if I just wanted to scan through the edge detector output and change the white pixels to random hue values how would I do that?

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/video.hpp"
#include <windows.h>
#include <iostream>

using namespace cv;
using namespace std;

inline void processBgs(const Ptr<BackgroundSubtractor>& p, Mat& f, Mat& fg, double rate){
     p->apply(f, fg, rate);
}

inline void processCanny(Mat& img, Mat& edges, int lowthresh, int hithresh, int sobelsize){
     Canny(img, edges, lowthresh, hithresh, sobelsize);
}

// I'm attempting to change pixels to any color here
void rainbow(Mat& img){
    for(int i=0; i<img.rows; i++){
        for(int j=0; j<img.cols; j++){

       Vec3b & color = img.at<Vec3b>(i,j);
        color[0] = 200;

        }
    }
}

int main(int argc, char** argv)
{
        VideoCapture cap(0);

        namedWindow( "Display window", CV_WINDOW_AUTOSIZE );
        HWND hwnd = (HWND)cvGetWindowHandle("Display window");

        Mat frame;
        Mat fgMask; 

        Ptr<BackgroundSubtractor> bgs = createBackgroundSubtractorMOG2();

        cap >> frame;

        cout << frame.type();
        imshow("Display window", frame);  

        while(IsWindowVisible(hwnd)) {
            cap >> frame;
            if(frame.empty()){ break; }
            processBgs(bgs, frame, fgMask, 0.01);
            processCanny(fgMask, fgMask, 50, 150, 3);
            cvtColor(fgMask, fgMask, CV_GRAY2RGB);
          //  cvtColor(fgMask, fgMask, CV_RGB2HSV);
            rainbow(fgMask);
            imshow("Display window", fgMask);     
            if(cvWaitKey(5) == 27){ break; }
        }

        waitKey(0); 
        return 0;
}
2018-01-08 19:31:34 -0600 received badge  Student (source)
2018-01-08 16:59:12 -0600 edited question trouble understanding pixel access

trouble understanding pixel access I am just getting into opencv and set up a demo just to get familiar. I made a func

2018-01-08 16:58:44 -0600 edited question trouble understanding pixel access

trouble understanding pixel access I am just getting into opencv and set up a demo just to get familiar. I made a func

2018-01-08 16:58:44 -0600 received badge  Editor (source)
2018-01-08 16:56:36 -0600 asked a question trouble understanding pixel access

trouble understanding pixel access I am just getting into opencv and set up a demo just to get familiar. I made a func

2017-03-13 04:39:37 -0600 received badge  Supporter (source)
2017-03-13 04:25:04 -0600 commented answer Where are module libs in prebuilt version?

Ok, I must have misunderstood. Thanks for clarifying. Just to clarify: In the Windows installation tutorial, where it refers to pre-built libraries, what is it referring to, are they precompiled binaries for the visual studio compiler? Edit: yes.

2017-03-13 04:24:54 -0600 received badge  Scholar (source)
2017-03-13 03:59:29 -0600 asked a question Where are module libs in prebuilt version?

I am trying to run my first example program, but I am getting undefined reference errors.

Im am using the prebuilt "vc14" folder with mingw32 and netbeans. I added the headers, lib and bin directories to the project, but the only .lib files to to link to were opencv_world320.lib or opencv_world320d.lib. There are Cmake files in the folder, but no other .lib files for the modules.

How am I supposed to get the modules?

Thanks for your help.