Ask Your Question

louis89's profile - activity

2021-04-11 14:16:27 -0600 received badge  Popular Question (source)
2020-03-19 18:27:33 -0600 received badge  Notable Question (source)
2019-10-18 06:28:49 -0600 received badge  Notable Question (source)
2019-10-18 04:21:55 -0600 received badge  Famous Question (source)
2019-02-19 03:25:36 -0600 received badge  Popular Question (source)
2019-01-24 06:43:32 -0600 received badge  Popular Question (source)
2018-12-26 01:00:25 -0600 received badge  Notable Question (source)
2018-09-06 09:07:53 -0600 received badge  Popular Question (source)
2017-09-13 12:49:05 -0600 marked best answer How to call a function in a main function With OpenCv and C++?

Hi.I use below code for video capture from my webcam:

Mat frame;
int threshval =120;
static void on_trackbar(int, void*)
{


 }
 int main(int argc, char* argv[])
 {

     VideoCapture cap(0);
     if (!cap.isOpened())
     {
         cout << "Cannot open the video cam" << endl;
         return  0;

     }

     while (1)
     {
         bool bSuccess = cap.read(frame); // Khandane yek frame jadid dar video


         if (!bSuccess)
         {
             cout << "Cannot read a frame from video stream" << endl;
             break;
         }
    createTrackbar("Threshold", "Image", &threshval, 255, on_trackbar);
    on_trackbar(threshval, 0);}
             return 0; }

I want to use a function that takes the image from video capture class and convert that frame to a gray level image and use Canny Edge Detector for that image.for this reason I use this function:

int my_cannyEdgeDetector(){

         cvtColor(frame, frame2, COLOR_BGR2GRAY);
         Canny(frame2, frame2, threshval, threshval * 2, 3);}

I know I wrote the wrong function but I'm begginer in opencv and c++ and I want to get pictures from the main function and put it in the my_cannyEdgeDetector function and imshow frame and frame2 in the end of my main function.I have no idea to set input and output for my_cannyEdgeDetector function.Thank you very much if you help me do this

2017-09-13 05:08:04 -0600 commented question How to call a function in a main function With OpenCv and C++?

@Volkmar .thanks for your reply.but where should I add your code to my program?another question is that Is not it necess

2017-09-13 04:10:51 -0600 asked a question How to call a function in a main function With OpenCv and C++?

How to call a function in a main function With OpenCv and C++? Hi.I use below code for video capture from my webcam: Ma

2017-09-12 08:21:39 -0600 commented question How to read all frame in a video without use VideoCapture function in opencv?

@berak can i display all frame with another way(except video capture)?

2017-09-12 08:21:23 -0600 commented question How to read all frame in a video without use VideoCapture function in opencv?

@berak can i display all frame with another way(except video capture)?

2017-09-12 08:15:08 -0600 commented question How to read all frame in a video without use VideoCapture function in opencv?

@berak I want to get image from my webcam .can I use a LOOP for display all frame One by one؟

2017-09-11 05:32:08 -0600 asked a question How to read all frame in a video without use VideoCapture function in opencv?

How to read all frame in a video without use VideoCapture function in opencv? hi.I'm beginner in OpenCV and c++.I use be

2017-09-04 12:13:49 -0600 edited question How to change OpenCv code in the form Function?

How to change OpenCv code in the form Function? Hi.I'm beginner in OpenCv and c++ code.in below you can see my program:

2017-09-04 03:02:59 -0600 commented answer Display a Text on the windows with OpenCv and c++

@LBerger thanks for your help. can you help me to definition this code in the form a function?

2017-09-03 01:16:57 -0600 commented question How to change OpenCv code in the form Function?

@sturkmen this is a detection program that I want to use it in a tracking program.

2017-09-02 15:26:53 -0600 edited question How to change OpenCv code in the form Function?

How to change OpenCv code in the form Function ? Hi.I'm beginner in OpenCv and c++ code.in below you can see my program:

2017-09-02 15:26:27 -0600 edited question How to change OpenCv code in the form Function?

How to change OpenCv code in the form Function for use in another program? Hi.I'm beginner in OpenCv and c++ code.in bel

2017-09-02 15:25:31 -0600 edited question How to change OpenCv code in the form Function?

How to change OpenCv code in the form Function for use in another program? Hi.I'm beginner in OpenCv and c++ code.in bel

2017-09-02 15:25:25 -0600 edited question How to change OpenCv code in the form Function?

How to change OpenCv code in the form Function for use in another program? Hi.I'm beginner in OpenCv and c++ code.in bel

2017-08-31 04:38:46 -0600 asked a question How to change OpenCv code in the form Function?

How to change OpenCv code in the form Function for use in another program? Hi.I'm beginner in OpenCv and c++ code.in bel

2017-08-30 05:08:28 -0600 marked best answer Display a Text on the windows with OpenCv and c++

Hi.I use below code for object detection:

static void on_trackbar(int, void*)
{
}
int main(int argc, char* argv[]) 
{
Mat frame;

Mat frame2 ;
VideoCapture cap(0);
if (!cap.isOpened())
{
    cout << "Cannot open the video cam" << endl;
    return  0;

}
namedWindow("Image", 1);
createTrackbar("Threshold", "Image", &threshval, 255, on_trackbar);

while (1)
{
    bool bSuccess = cap.read(frame); // read a new frame from video


    if (!bSuccess)
    {
        cout << "Cannot read a frame from video stream" << endl;
        break;
    }

    cvtColor(frame, frame2, COLOR_BGR2GRAY);
    GaussianBlur(frame2, frame2, Size(5, 5), 0);
    Canny(frame2, frame2, threshval, threshval * 2, 3);
    morphologyEx(frame2, frame2, MORPH_CLOSE, Mat(), Point(-1, -1), 2);
    Mat stat, centroid;
    Mat bw = threshval < 128 ? (frame2< threshval) : (frame2 > threshval);
    Mat labelImage(frame2.size(), CV_32S);
    int nLabels = connectedComponentsWithStats(bw, labelImage, stat, centroid, 8);

    std::vector<Vec3b> colors(nLabels);
    colors[0] = Vec3b(0, 0, 0);//background
    for (int label = 1; label < nLabels; ++label) 
    {
        colors[label] = Vec3b((rand() & 255), (rand() & 255), (rand() & 255));
    }
    Mat dst(frame2.size(), CV_8UC3);
    for (int r = 0; r < dst.rows; ++r) 
    {
        for (int c = 0; c < dst.cols; ++c) 
        {
            int label = labelImage.at<int>(r, c);
            Vec3b &pixel = dst.at<Vec3b>(r, c);
            pixel = colors[label];
        }
    }
    for (int i = 0; i < nLabels; i++)
    {
        if (stat.at<int>(i, CC_STAT_AREA) <80 && stat.at<int>(i, CC_STAT_AREA) >10) 
        {

            cout << "mitter"<<endl;

        }
    }

    imshow("Image", frame2);

    if (waitKey(1) == 27)
    {
        cout << "esc key is pressed by user" << endl;
        break;
    }

}
return 0;

} I want to have a text on window that show "Detection off" and when the condition if (stat.at<int>(i, CC_STAT_AREA) <80 && stat.at<int>(i, CC_STAT_AREA) >10) was fulfilled then the Text in the window change to "Detection On".I'm beginner in OpenCv and c++ and I have no idea to do this.I'm so grateful to help me do this

2017-08-29 08:54:38 -0600 edited question Display a Text on the windows with OpenCv and c++

Display a Text on the windows with OpenCv and c++ Hi.I use below code for object detection: static void on_trackbar(in

2017-08-29 08:42:29 -0600 commented question Display a Text on the windows with OpenCv and c++

@Ziri I have two text:1-"Detection OFF" 2-"Detection ON".I want to displayed only "Detection ON" if the condition is tru

2017-08-29 08:25:25 -0600 commented answer Display a Text on the windows with OpenCv and c++

@LBerger this program only show" mitter" if stat.at<int>(i, CC_STAT_AREA) <80....but I want to change the text

2017-08-29 05:19:11 -0600 commented question Display a Text on the windows with OpenCv and c++

@Ziri no.I try this but "Detection off" still exist when the condition was fulfilled.

2017-08-29 03:28:01 -0600 commented question Display a Text on the windows with OpenCv and c++

@Ziri yes.in this way I have two Text,that "Detection Off" is Always in the picture and "Detection On" while the condi

2017-08-29 03:27:27 -0600 commented question Display a Text on the windows with OpenCv and c++

yes.in this way I have two Text,that "Detection Off" is Always in the picture and "Detection On" while the condition w

2017-08-29 02:33:22 -0600 commented question Display a Text on the windows with OpenCv and c++

@Ziri but how?can you show me?I want to have a text on frame that show "Detection off" and when the condition if (stat.a

2017-08-29 02:33:00 -0600 commented question Display a Text on the windows with OpenCv and c++

but how?can you show me?I want to have a text on frame that show "Detection off" and when the condition if (stat.at<i

2017-08-28 12:05:27 -0600 commented question Display a Text on the windows with OpenCv and c++

@Ziri can I change text after a condition?

2017-08-28 08:37:43 -0600 commented question Display a Text on the windows with OpenCv and c++

@LBerger thanks for your reply.This program works well for monochrome object, but it does not work well for an object

2017-08-28 07:45:17 -0600 commented question Display a Text on the windows with OpenCv and c++

@LBerger thanks for your reply.This program works well for monochrome object, but it does not work well (for example, o

2017-08-28 07:44:11 -0600 commented question Display a Text on the windows with OpenCv and c++

@LBerger thanks for your reply.This program works well for monochrome, but it does not work well (for example, only the

2017-08-28 04:53:29 -0600 asked a question Display a Text on the windows with OpenCv and c++

Display a Text on the windows with OpenCv and c++ Hi.I use below code for object detection: Mat frame; cv::Mat frame

2017-08-02 17:05:35 -0600 commented answer Change the location of a fixed rectangle in the image by moving the mouse

I solve it.the problem was #include <opencv2\opencv.hpp>

2017-08-02 16:01:05 -0600 commented answer Change the location of a fixed rectangle in the image by moving the mouse

yes.I do this.I use cmake for build opencv3.3_rc and Without receiving any errors I succeeded to build it in visual studio 2015.I use this version of opencv for another program(for example connected component) but when I use your code in this version of opencv,my program stops without getting any errors

2017-08-02 14:08:55 -0600 commented answer Change the location of a fixed rectangle in the image by moving the mouse

yes.your program works very well in opencv2.4.13 but when I use this program in opencv3.0.0 or opencv3.3_rc I'm having trouble hanging up the computer

2017-08-02 13:52:25 -0600 marked best answer Change the location of a fixed rectangle in the image by moving the mouse

I am using OpenCV for a C++ application.I have a fixed rectangle in my image.I want when I click on the mouse on the rectangle,than The rectangle position changes to where the mouse is released.I'm beginner in opencv and c++.do you have any idea to do this?this is my code:

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;
using namespace std;

int main()
{
// Open the video file
VideoCapture capture("blowcontrast1.avi");

if (!capture.isOpened())
    return 1;

bool stop(false);
Mat frame; //current video frame
namedWindow("Extracted Frame");
int delay = 1;

cout << capture.get(CV_CAP_PROP_FPS);
capture.set(CV_CAP_PROP_POS_AVI_RATIO, 0.5);

while (!stop)
{
    if (!capture.read(frame))
        break;
            Rect rectangle(200 , 150, 40, 40);
            rectangle(frame, rectangle, Scalar(255, 255, 255));
    imshow("Extracted Frame", frame);

    if (waitKey(delay) >= 0)
        stop = true;
}

waitKey();
}