Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

use create Trackbar for Threshold value

I have a Threshold function that For Various Images Minimum amount of Threshold Changes Between 0.00001 and 0.001 and the maximum amount of threshold is 255. I want to use Trackbar for specify minimum amount of Threshold.can you help me to do this?thanks a lot...

use create Trackbar for Threshold Threshold's value

I have a Threshold function that For Various Images Minimum amount of Threshold Changes Between 0.00001 and 0.001 and the maximum amount of threshold is 255. I want to use Trackbar for specify minimum amount of Threshold.can you help me to do this?thanks a lot...

use create Trackbar for Threshold's value

I have a Threshold function that For Various Images Minimum amount of Threshold Changes Between 0.00001 and 0.001 and the maximum amount of threshold is 255. I want to use Trackbar for specify minimum amount of Threshold.can you help me to do this?thanks a lot...

int main(int argc, char* argv[]){
VideoCapture cap(0); 
if (!cap.isOpened()){
    cout << "Cannot open the video cam" << endl;
    return -1;}
int totalFrameNumber = cap.get(CV_CAP_PROP_FRAME_COUNT);
Mat frame;
namedWindow("MyVideo", CV_WINDOW_AUTOSIZE);
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;
}
Rect rectangle2(420,280, 40, 40);
rectangle(frame, rectangle2, Scalar(255, 255, 255));
Mat cornerstrength;
cornerHarris(frame, cornerstrength, 3, 3, 0.1);
//threshold the corner strength
Mat harriscorners;
double th = 0.00001;
threshold(cornerstrength, harriscorners, th, 255, THRESH_BINARY);
morphologyEx(harriscorners, harriscorners, MORPH_CLOSE, Mat(), Point(-1, -1), 6);
//local maxima detection
Mat dilated, localMax;
dilate(cornerstrength, dilated, Mat());
compare(cornerstrength, dilated, localMax, CMP_EQ);
threshold(cornerstrength, harriscorners, th, 255, THRESH_BINARY);
harriscorners.convertTo(harriscorners, CV_8U);
bitwise_and(harriscorners, localMax, harriscorners);
harriscorners.convertTo(harriscorners, CV_32F);
Mat S(0, 2, CV_32SC1);

//drawing a circle around corners

for (int j = 0;j < harriscorners.rows;j++)
    for (int i = 0;i < harriscorners.cols;i++)
    {

        if (harriscorners.at<float>(j, i)> 0)
        {    circle(frame, Point(i, j), 5, Scalar(255), 2, 8);
            Mat pt(1, 2, CV_32SC1);
            pt.at<int>(1, 0) = i;
            pt.at<int>(0, 1) = j;
            // Add the point to S
            S.push_back(pt);
            for (int x = 430; x < 460; x++)
                for (int y = 285; y < 315; y++)
                    if  ((pt.at<int>(1, 0) = i) == x && (pt.at<int>(0, 1) = j) == y))


                    {
                        Rect rectangle2(430, 285, 30,30);}}}
imshow("MyVideo", frame);
if (waitKey(30) == 27)
            {
                cout << "esc key is pressed by user" << endl;
                break;
            }
        }

        return 0;
    }

use create Trackbar for Threshold's value

I have a Threshold function that For Various Images Minimum amount of Threshold Changes Between 0.00001 and 0.001 and the maximum amount of threshold is 255. I want to use Trackbar for specify minimum amount of Threshold.can you help me to do this?thanks a lot...

int main(int argc, char* argv[]){
VideoCapture cap(0); 
if (!cap.isOpened()){
    cout << "Cannot open the video cam" << endl;
    return -1;}
int totalFrameNumber = cap.get(CV_CAP_PROP_FRAME_COUNT);
Mat frame;
namedWindow("MyVideo", CV_WINDOW_AUTOSIZE);
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;
}
Rect rectangle2(420,280, 40, 40);
rectangle(frame, rectangle2, Scalar(255, 255, 255));
Mat cornerstrength;
cornerHarris(frame, cornerstrength, 3, 3, 0.1);
//threshold the corner strength
Mat harriscorners;
double th = 0.00001;
threshold(cornerstrength, harriscorners, th, 255, THRESH_BINARY);
morphologyEx(harriscorners, harriscorners, MORPH_CLOSE, Mat(), Point(-1, -1), 6);
//local maxima detection
Mat dilated, localMax;
dilate(cornerstrength, dilated, Mat());
compare(cornerstrength, dilated, localMax, CMP_EQ);
threshold(cornerstrength, harriscorners, th, 255, THRESH_BINARY);
harriscorners.convertTo(harriscorners, CV_8U);
bitwise_and(harriscorners, localMax, harriscorners);
harriscorners.convertTo(harriscorners, CV_32F);
Mat S(0, 2, CV_32SC1);

//drawing a circle around corners

for (int j = 0;j < harriscorners.rows;j++)
    for (int i = 0;i < harriscorners.cols;i++)
    {

        if (harriscorners.at<float>(j, i)> 0)
        {    circle(frame, Point(i, j), 5, Scalar(255), 2, 8);
            Mat pt(1, 2, CV_32SC1);
            pt.at<int>(1, 0) = i;
            pt.at<int>(0, 1) = j;
            // Add the point to S
            S.push_back(pt);
            for (int x = 430; x < 460; x++)
                for (int y = 285; y < 315; y++)
                    if  ((pt.at<int>(1, 0) = i) == x && (pt.at<int>(0, 1) = j) == y))
                     {
                        Rect rectangle2(430, 285, 30,30);}}}
cout<<"louis89"<<endl;}}}
imshow("MyVideo", frame);
if (waitKey(30) == 27)
            {
                cout << "esc key is pressed by user" << endl;
                break;
            }
        }

        return 0;
    }

use create Trackbar for Threshold's value

I have a Threshold function that For Various Images Minimum amount of Threshold Changes Between 0.00001 and 0.001 and the maximum amount of threshold is 255. I want to use Trackbar for specify minimum amount of Threshold.can you help me to do this?thanks a lot...

int main(int argc, char* argv[]){
VideoCapture cap(0); 
if (!cap.isOpened()){
    cout << "Cannot open the video cam" << endl;
    return -1;}
int totalFrameNumber = cap.get(CV_CAP_PROP_FRAME_COUNT);
Mat frame;
namedWindow("MyVideo", CV_WINDOW_AUTOSIZE);
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;
}
Rect rectangle2(420,280, 40, 40);
rectangle(frame, rectangle2, Scalar(255, 255, 255));
Mat cornerstrength;
cornerHarris(frame, cornerstrength, 3, 3, 0.1);
//threshold the corner strength
Mat harriscorners;
double th = 0.00001;
threshold(cornerstrength, harriscorners, th, 255, THRESH_BINARY);
morphologyEx(harriscorners, harriscorners, MORPH_CLOSE, Mat(), Point(-1, -1), 6);
//local maxima detection
Mat dilated, localMax;
dilate(cornerstrength, dilated, Mat());
compare(cornerstrength, dilated, localMax, CMP_EQ);
threshold(cornerstrength, harriscorners, th, 255, THRESH_BINARY);
harriscorners.convertTo(harriscorners, CV_8U);
bitwise_and(harriscorners, localMax, harriscorners);
harriscorners.convertTo(harriscorners, CV_32F);
Mat S(0, 2, CV_32SC1);

//drawing a circle around corners

for (int j = 0;j < harriscorners.rows;j++)
    for (int i = 0;i < harriscorners.cols;i++)
    {

        if (harriscorners.at<float>(j, i)> 0)
        {    circle(frame, Point(i, j), 5, Scalar(255), 2, 8);
            Mat pt(1, 2, CV_32SC1);
            pt.at<int>(1, 0) = i;
            pt.at<int>(0, 1) = j;
            // Add the point to S
            S.push_back(pt);
            for (int x = 430; x < 460; x++)
                for (int y = 285; y < 315; y++)
                    if  ((pt.at<int>(1, 0) = i) == x && (pt.at<int>(0, 1) = j) == y))
                    {
                       cout<<"louis89"<<endl;}}}
imshow("MyVideo", frame);
if (waitKey(30) == 27)
            {
                cout << "esc key is pressed by user" << endl;
                break;
            }
        }

        return 0;
    }
click to hide/show revision 6
retagged

use create Trackbar for Threshold's value

I have a Threshold function that For Various Images Minimum amount of Threshold Changes Between 0.00001 and 0.001 and the maximum amount of threshold is 255. I want to use Trackbar for specify minimum amount of Threshold.can you help me to do this?thanks a lot...

int main(int argc, char* argv[]){
VideoCapture cap(0); 
if (!cap.isOpened()){
    cout << "Cannot open the video cam" << endl;
    return -1;}
int totalFrameNumber = cap.get(CV_CAP_PROP_FRAME_COUNT);
Mat frame;
namedWindow("MyVideo", CV_WINDOW_AUTOSIZE);
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;
}
Rect rectangle2(420,280, 40, 40);
rectangle(frame, rectangle2, Scalar(255, 255, 255));
Mat cornerstrength;
cornerHarris(frame, cornerstrength, 3, 3, 0.1);
//threshold the corner strength
Mat harriscorners;
double th = 0.00001;
threshold(cornerstrength, harriscorners, th, 255, THRESH_BINARY);
morphologyEx(harriscorners, harriscorners, MORPH_CLOSE, Mat(), Point(-1, -1), 6);
//local maxima detection
Mat dilated, localMax;
dilate(cornerstrength, dilated, Mat());
compare(cornerstrength, dilated, localMax, CMP_EQ);
threshold(cornerstrength, harriscorners, th, 255, THRESH_BINARY);
harriscorners.convertTo(harriscorners, CV_8U);
bitwise_and(harriscorners, localMax, harriscorners);
harriscorners.convertTo(harriscorners, CV_32F);
Mat S(0, 2, CV_32SC1);

//drawing a circle around corners

for (int j = 0;j < harriscorners.rows;j++)
    for (int i = 0;i < harriscorners.cols;i++)
    {

        if (harriscorners.at<float>(j, i)> 0)
        {    circle(frame, Point(i, j), 5, Scalar(255), 2, 8);
            Mat pt(1, 2, CV_32SC1);
            pt.at<int>(1, 0) = i;
            pt.at<int>(0, 1) = j;
            // Add the point to S
            S.push_back(pt);
            for (int x = 430; x < 460; x++)
                for (int y = 285; y < 315; y++)
                    if  ((pt.at<int>(1, 0) = i) == x && (pt.at<int>(0, 1) = j) == y))
                    {
                       cout<<"louis89"<<endl;}}}
imshow("MyVideo", frame);
if (waitKey(30) == 27)
            {
                cout << "esc key is pressed by user" << endl;
                break;
            }
        }

        return 0;
    }