Ask Your Question

dmcenan's profile - activity

2019-02-26 11:11:07 -0500 received badge  Notable Question (source)
2018-12-13 02:16:23 -0500 received badge  Popular Question (source)
2018-10-14 23:39:40 -0500 received badge  Popular Question (source)
2013-11-28 19:30:33 -0500 asked a question Matx Data-Type Short-Hand Rules?

Hi Guys, I was reviewing the various OpenCV data types and have a question about the Matx data type (the question also applies to the Vec data type).

We know that you can declare a Matx object using regular notation and short hand notation as below (to define a 2x2 matrix):

Matx<float,2,2> m1 = {1.1,2.2,3.3,4.4};     //regular notation

Matx22f m2 = {1.1,2.2,3.3,4.4};         //shorthand notation

From testing I can see that there are limitations on what size dimensions can be used for short hand notation. For example we can write Matx43f but not Matx42f to define a 4x2 matrix of floats.

Why is this and is there some standard rule for determining what dimensions can be used when defining Vec's or Matx's? Also why can't we use short-hand notation to declare a Matx of int's using Matx22i? It seems really confusing and I wish it was somehow standardized.

Thanks!

2013-11-27 22:57:52 -0500 received badge  Supporter (source)
2013-11-27 22:57:37 -0500 commented answer Iterating Through a Video Frame by Frame

Hello Martin, Thank you for taking the time to compose a concise and clear explanation. This helps a lot! Regards, dmcenen.

2013-11-27 15:12:03 -0500 asked a question Iterating Through a Video Frame by Frame

Hi Folks, In the code below (for playing a video), how does the capture object "know" how to iterate through the video frame by frame? Usually in a while or for loop we use some sort of incrementing technique such as i++ etc.

I think I have seen this before with stream extraction iterators where they automatically increment to read the contents of a buffer but I am not sure how it works. I tried to view the contents of the Videocapture class but can only find the definition (which includes an overloaded>> function) but can not see how it is implemented.

Thanks,

int main()

{ namedWindow("Video"); VideoCapture cap;

cap.open("video.avi");

Mat frame;

while(1)
{
    cap>>frame;     
    if(!frame.data) 
        break;

    imshow("Video", frame);

    if(waitKey(300) >= 0)   
        break;              
}

}

2013-11-25 13:18:31 -0500 commented question Help to Open Video File

Thanks Haris, I tried the code on a Windows PC and it ran fine. There must be some difference with my Linux setup but I am not sure what....as far as I can see I have all the requirements for the code to run. I'll see if I can figure it out.

2013-11-24 20:49:08 -0500 asked a question Help to Open Video File

Hi Folks, When I use the code below to open a video, 0 is always returned for the cap.isOpened() function call. I tried numerous videos and formats and below I am using a sample AVI file from an official openCV tutorial so I know the format/codec is not an issue. I am using Linux Mint 15 with ffmpeg 0.8.9 installed and OpenCV 2.5. For an IDE I am using Eclipse Juno.

I have placed the avi video in the same folder as the exe (the Debug folder) and also in the project directory (when I store images in the project directory they always load so I don't think it is an issue on OpenCV not being able to locate the video file).

Does anyone know why the code below does not work? Does the code below work for anyone else, even with using a different video?

int main()
{
namedWindow("Video");
VideoCapture cap;

cap.open("Megamind.avi");
cout<<cap.isOpened()<<endl; //ALWAYS returns 0!

Mat frame;

    while(1)
    {
        cap>>frame;
        if(!frame.data)
            break;

        imshow("Video", frame);

        if(waitKey(33) >= 0)
            break;
    }
}
2013-11-13 16:58:04 -0500 commented answer What is the Kernel Doing in a Blur Function?

Thanks for your reply Guanta!

2013-11-07 17:21:06 -0500 asked a question What is the Kernel Doing in a Blur Function?

Hi Folks, If I have the following input pixels and I apply the blur funtion below, what value will the middle pixel change to? In the case of a 3x3 kernel, does OpenCV take all 9 pixels and then use the average for the "new" middle pixel changing it from 50 to 94? Or does it take the average of all pixels in the 3x3 kernel except the middle pixel, which would mean 50 changes to 100?

Also, does it make sense to use a kernel size of (1,1)? This does work and OpenCv will process an image and change the pixels but I am not sure what pixels it considers for a kernel size of (1,1). In all cases the anchor is in the center of the kernel.

Thanks!

100 100 100

100 50 100

100 100 100

blur(image, result, Size(3,3), Point(-1,-1));
2013-10-20 18:25:06 -0500 received badge  Scholar (source)
2013-10-19 17:08:42 -0500 commented answer Solid Fill Rectangle Error [LineType Parameter?]

Thank you for your reply Berak. I am not too sure what to conclude here but I will stick with the default lineType value of 8. Some lineType values seem to depend on the thickness parameter for some reason. For example when thickness = 2 and lineType = 2 the code above runs fine but when I change the thickness to 1, a run time errorr occurs. With both thickness and lineType set to 1, the code again runs fine!

2013-10-19 15:19:12 -0500 asked a question Solid Fill Rectangle Error [LineType Parameter?]

Hi Folks,

When creating shapes with OpenCV, can someone tell me what the "LineType" parameter is? From the definition of the various shapes, it appears that linetype has a default value of 8. What is curious though, is when I use the code below to create a solid fill rectangle, the code produces a run time error whenever I use values of [2,3,5,6,7] for the LineType along with a value of -1 for the thickness (to produce a solid fill rectangle). However, when I change the thickness value to 6 and leave the linetype = 2, the code runs fine. Why is this??

Error: Assertion failed (connectivity == 8 || connectivity == 4) in LineIterator

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

using namespace std;
using namespace cv;

//solid fill rectangle example
    int main()
    {
        Mat image(200, 200, CV_8UC3, Scalar(255,0,0));

        Point start = Point (50,50);
        Point end = Point (150,150);
        int thickness = -1;
        int linetype =2; //error

        rectangle (image, start, end, Scalar(0,255,0), thickness, linetype);

        namedWindow("Image");
        imshow("Image", image);

    waitKey(0);
    }
2013-10-04 21:27:04 -0500 received badge  Editor (source)
2013-10-04 21:25:51 -0500 answered a question Single Pixel Colors

Hi guys thanks for your replies.

Michael, below is the exact code I am using (GCC 4.7.2, OpenCV 2.4.5) but when I change the last parameter in the Mat declaration from 001 to 0 or 000 etc to represent black, the program compiles fine but generates the following runtime error (Why is this?):

OpenCV Error: Null pointer (The matrix has NULL data pointer) in cvGetMat, file /home/dme/Documents/opencv-2.4.5/modules/core/src/array.cpp, line 2387 terminate called after throwing an instance of 'cv::Exception' what(): /home/dme/Documents/opencv-2.4.5/modules/core/src/array.cpp:2387: error: (-27) The matrix has NULL data pointer in function cvGetMat

#include <opencv2 core="" core.hpp=""> #include <opencv2 highgui="" highgui.hpp=""> #include <iostream>

using namespace std;
using namespace cv;

int main()
{
    Mat blackImage(200, 200, CV_8U, 001);

    namedWindow("Black");
    imshow("Black", blackImage);

waitKey(0);
}
2013-10-02 20:45:46 -0500 asked a question Single Pixel Colors

Hi Folks,

I am just starting out with openCV and I understand how a 3 channel image uses a combination of RGB values to display a color image. The code below will produce a black and a white window but where do these values come from? Where is it specified that the values from 001 to 255 span the colors black to white with shades of grey in between? Is there a lookup chart like there is for color images with 3 values per pixel?

Also when I draw a circle, openCV let's me specify the color as '0' which is equal to black. When I use '0' or '000' in the code below, openCV produces an error. Why is that?

Mat blackImage(200, 200, CV_8U, 001);

Mat whiteImage(200, 200, CV_8U, 255);

Thanks.