Ask Your Question

william13200's profile - activity

2019-05-04 10:45:23 -0600 received badge  Notable Question (source)
2017-04-29 13:28:36 -0600 received badge  Popular Question (source)
2013-08-17 15:03:59 -0600 asked a question Hough circles method detection on a videoFrame

Hi everyone, my different codes to detect circles do work well on single images but for my application i would need to apply it to a video frame (image extracted from a videoCapture). Basicly what i do is to get the video frame and simply place it where i used to have my source from a simple "imread(..)". But what happens is that after all the filtering and processing,imshow returns the normal capture, and i would like the circles to be drawn.

this is my code:

VideoCapture video(0);
Mat videoFrame;
Mat cannyOutput,imgBW;
vector<Vec4i> hierarchy;
vector<vector<Point> > contours;
vector<Moments> muCercle;
vector<Point2f> mcCercle;

if (video.isOpened() == false ){
    std::cout<<"Erreur ouverture video"<<std::endl;
 }

while(! ( (cv::waitKey(1)) ==  'q' ) ){

    //recupere la videoFrame
    video >> videoFrame;
    /// Convert it to gray
    cvtColor( videoFrame, imgBW, CV_BGR2GRAY );
    /// Reduce the noise so we avoid false circle detection
    GaussianBlur(imgBW, imgBW, Size(9, 9), 2, 2 );

    vector<Vec3f> circles;
    /// Apply the Hough Transform to find the circles
    HoughCircles(imgBW, circles, CV_HOUGH_GRADIENT, 1, imgBW.rows/8, 200, 100, 0, 0 );

    /// Draw the circles detected
    for( size_t i = 0; i < circles.size(); i++ )
        {
        Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
        int radius = cvRound(circles[i][2]);
        // circle center
        circle( videoFrame, center, 3, Scalar(0,255,0), -1, 8, 0 );
        // circle outline
        circle( videoFrame, center, radius, Scalar(0,0,255), 3, 8, 0 );
        }

     /// Show your results
     namedWindow("w", CV_WINDOW_AUTOSIZE );
     imshow("w", videoFrame );
     cv::waitKey(10);       
 }//tant que non stop
cvDestroyAllWindows();
video.release();

I tried to use more delay but it didn't change anything, it doesn't seem to be a processing problem. I also tried to put the "video >> videoFrame" (acquire the image extracted from the video) out of the infinite loop so i get a simple image and just treat it, didn't fix it either. I think i'm doing something wrong with probably: a Mat or Array being output-input in one of all these functions or probably video >> videoFrame is doing something wrong.

Any ideas?

2013-07-26 09:09:16 -0600 received badge  Necromancer (source)
2013-06-07 13:29:17 -0600 received badge  Student (source)
2013-06-07 09:01:03 -0600 commented answer vector out of range

thanks for your help mate!

the problem was:

i can declare the muCircle, contours, matrix and all variables i need outside the function so i can use them in other functions. BUT, vector<moments> muCircle ( for instance ) , vector<points> etc.. NEED: muCircle.resize(contours.size()); inside the function

2013-06-07 08:23:48 -0600 asked a question vector out of range

Hi there, working on a robotics application.

My program is crashing at this exact point ( i'm proceeding the edges and findcontours operations) it used to work but it seems it doesn't anymore since i moved the Mat and all the declarations out of the function to put it in the whole file, so i can access it in other functions.

void Edges() {

imread then cvtcolor .. blur .. canny.. findcontours.. etc.. it all works.

now i'm proceeding:

for (unsigned int i = 0; i<contours.size(); i++){
drawContours(drawing,contours,i,(255,255,255),1,8,hierarchy,0,point() );

this works again and now:

for (unsigned int i =0; i<contours.size(); i++){
muCircle[i] = moments (contours[i],false);

once this is reached it crashes and i get:

Debug assertion failed
vector subscript out of range.

on msdn i can read that this kind of error is due to accessing a vector value which doesn't exist. But thanks to the debug flag, i can see that the program does crash at this very exact point. and until then i never use vector.

any ideas??

2013-06-04 06:20:50 -0600 commented answer Getting a shape out of edges Canny algorithm

thanks, very helpful!

2013-06-04 04:46:45 -0600 asked a question Getting a shape out of edges Canny algorithm

Hi there, i'm extracting an img from a file ( then i will be doing this from a capture ) and i'm using canny algorithms in order to get its edges. this works fine but i guess i'm stuck here because it doesn't seem obvious how to use this result:

i would like to get something like a shape that would fit the best way as possible the edge of the result. How would you do this?

for instance: getting the edges of a building, how would you actually get the rectangular shape out of it?

NB: cvtColor (image,imageGray,CV_BGR2GRAY); blur(imageGray,edge,Size(3,3)); Canny(edge,edge,edgeThresh,edgeThresh*3,3); Cedge = Scalar::all(0); // important image.copyTo(Cedge,edge);

i'm converting to Gray then processing the canny algorithm. Do you think rather converting to black&white would give better result?

2013-05-28 04:42:32 -0600 answered a question OpenCV 2.4 install problem

ok so you get compile & debugg? are you trying to use the default webcam? this is done by cvCaptureFromCAM(0); then you need delay to process the video frames in your infinite loop this is done by: waitKey(x);

2013-05-28 04:35:13 -0600 commented answer Opencv .lib used to work but not anymore

OK Thank you for the tips; I'm adding the build directory and getting errors when generating the file. do you think this is the problem?

example of errors: "imshow .. video ... namedWindow.. unidentified, unfoundable"

2013-05-27 13:31:39 -0600 answered a question Opencv .lib used to work but not anymore

Still need help, changing to x64, removing %build% didn't change anything anyone could give me some advices please? thank for your time

2013-05-25 03:11:28 -0600 answered a question Opencv .lib used to work but not anymore

i used x64 everywhere and it didn't change anything, changing %build% to the full path neither could anyone help me out?

2013-05-24 11:09:53 -0600 answered a question Opencv .lib used to work but not anymore

anyone could help me ? changing to x64 & not using %build% but the full path doesn't change anything

2013-05-22 08:50:45 -0600 asked a question Opencv .lib used to work but not anymore

Hi there, i'm using VS2012 and i got everything working for the past few weeks thanks to some people here helping me out. I've been working on using serial libraries and opencv at the same time, and now i've got everything bugging again it's driving me nuts.

my OS is 64 bits my environmnt variables are: added a new variable "OPENCV_BUILD" ( with the value c:\opencv\build ) ( i got this from the last tutorial i've been folowing, since the other didn't work anymore)

system path i've added : %OPENCV_BUILD%\x86\vc11\bin (without the";" because it's the very last one)

then in my VS project: -> properties -> C/C++ -> general -> -> $(OPENCV_BUILD)\include;

-> linker -> general -> added lib directories -> $(OPENCV_BUILD)\x86\vc11\lib;

-> input -> other depedences -> opencv_core244d.lib;etc... all the d.lib

when i code i got everything well recognised again ( blue words, libraries not underlined) but when i compile i get ERROR Cxxxx: 'cv' is not a class name 'image' 'waitkey' 'imshow' etc.. unfound or undeclared identifier

what i am doing wrong? only using the PATH environmnt variable i got the same problem do you think i should use x64 rather than x86? ( it used to work for 86 )

I had a lot of trouble getting opencv working and all of a sudden i got everything bugging again.. What could have cause this kind of trouble??

2013-04-12 06:25:46 -0600 commented answer processing Video frames

Ok i'm just used to do not waste space in forums in general :p thanks a lot guys you are great. That wasnt obvious for me that waitKey was used to create the delay to process the video frames.

2013-04-12 00:19:30 -0600 commented answer processing Video frames

Ok (laugh) i found it :p could you please have a look above. I just didn't want to create another thread

2013-04-12 00:17:22 -0600 received badge  Scholar (source)
2013-04-11 15:07:05 -0600 commented answer processing Video frames

and how do i do that?? :/ i'm trying to add a new comment for another pb, have a look up there, not creating another thread

2013-04-11 14:25:36 -0600 answered a question processing Video frames

Hi there i've been playing a little bit discovering openCv on VS12, everything works fine for me concerning image processing. But i have a problem for processing video: i'm following basic tutorials, but when i compile, i only get one single frame through the video input. Where could this come from? I think i have a problem handling my frame, but i've been stricly following tutorials, this is what i write:

void main() { //example from a book

cv::VideoCapture capture(0);

if (!capture.isOpened())

    std::cout<<"not opened" <<std::endl;

// Get the frame rate

double rate= capture.get(CV_CAP_PROP_FPS);

bool stop(false);

cv::Mat frame; // current video frame

cv::namedWindow("Extracted Frame");

// Delay between each frame in ms // corresponds to video frame rate

int delay= 1000/rate;

// for all frames in video

while (!stop) {

// read next frame if any

    if (!capture.read(frame))
        break;

    cv::imshow("Extracted Frame",frame);

// introduce a delay // or press key to stop

    if (cv::waitKey(delay)>=0)
        stop= true;

} // Close the video file. // Not required since called by destructor capture.release(); }

//another version i personnaly wrote void main (void){ bool stop; stop = false; cv::VideoCapture capture (0); //capture from the webcam

if(capture.isOpened() == false ){
    std::cout<< "Capture Error" <<std::endl;
}//test if opned

cv::Mat frame;
cv::namedWindow("w");

double rate= capture.get(CV_CAP_PROP_FPS);


while (stop == false){
    frame=capture.read();
    if (!capture.read(frame))
        break;


    if (cvWaitKey() ){
        stop = true;
    }

    cv::imshow("w",frame);

}// chose while
capture.release();
cvDestroyWindow("w");

}

everytime i get the same thing: One single image from the cam does appear, and then i can push any key to stop, but i dont get a video frame

2013-04-08 12:37:54 -0600 commented answer processing Video frames

i've been following these tutorials and it's the exact solution i needed. Thanks A LOT for your help, it's been at least a month i tried to get it working.

2013-04-08 12:05:36 -0600 commented answer processing Video frames

thanks a lot for your answer. I'll try doing this way. what you mean is only using openCv as a pure library? I tried building a VS2012 basic application but it seems libraries can't work

What do you call prebuild binaries? i mean in which folders are they supposed to be? is it /opencv/build/x86/vc11/ bin lib and static lib in my case?

2013-04-07 14:45:43 -0600 received badge  Editor (source)
2013-04-07 14:41:53 -0600 asked a question processing Video frames

Hi there, i've been struggling for the last month trying to get it working.. i thought i could use some help:

i'm using windows 7 64bits with VS12 (from dreamspark)

i've installed opencv at C:Root and also Cmake.

The first pb i get is that, when i'm running cmake i get this error:

CMake was unable to find a build program corresponding to "Visual Studio 9 2008 Win64". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.strong text

when i click on configure i only have choices for VS5 to 9, not VS12 nor 11. everysingle option gives me the same error.

i guess i have a problem with my VS12 compiler. I think i've added the opencv binaries the proper way (x64 x86 bin in sys.path), but what seems weird is that in my system path, i don't have anything mentionning VS12 nor VS11. I've noticed in my program files i only have VS11. Are they using the same compiler?

I need help because i've been stuck for too long, thanks a lot if anyone can help me out..