Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8023291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:31:28+00:00 2026-06-04T22:31:28+00:00

#include <cv.h> #include <highgui.h> #include <math.h> int main(int argc, char** argv) { IplImage* src;

  • 0
#include <cv.h>
#include <highgui.h>
#include <math.h>

int main(int argc, char** argv)
{
    IplImage* src;
    if( argc == 2 && (src=cvLoadImage("qqqq.jpg", 0))!= 0)
    {
        IplImage* dst = cvCreateImage( cvGetSize(src), 8, 1 );
        IplImage* color_dst = cvCreateImage( cvGetSize(src), 8, 3 );
        CvMemStorage* storage = cvCreateMemStorage(0);
        CvSeq* lines = 0;
        int i;
        cvCanny( src, dst, 50, 200, 3 );
        cvCvtColor( dst, color_dst, CV_GRAY2BGR );
#if 1
        lines = cvHoughLines2( dst,
                               storage,
                               CV_HOUGH_STANDARD,
                               1,
                               CV_PI/180,
                               100,
                               0,
                               0 );

        for( i = 0; i < MIN(lines->total,100); i++ )
        {
            float* line = (float*)cvGetSeqElem(lines,i);
            float rho = line[0];
            float theta = line[1];
            CvPoint pt1, pt2;
            double a = cos(theta), b = sin(theta);
            double x0 = a*rho, y0 = b*rho;
            pt1.x = cvRound(x0 + 1000*(-b));
            pt1.y = cvRound(y0 + 1000*(a));
            pt2.x = cvRound(x0 - 1000*(-b));
            pt2.y = cvRound(y0 - 1000*(a));
            cvLine( color_dst, pt1, pt2, CV_RGB(255,0,0), 3, 8 );
        }
#else
        lines = cvHoughLines2( dst,
                               storage,
                               CV_HOUGH_PROBABILISTIC,
                               1,
                               CV_PI/180,
                               80,
                               30,
                               10 );
        for( i = 0; i < lines->total; i++ )
        {
            CvPoint* line = (CvPoint*)cvGetSeqElem(lines,i);
            cvLine( color_dst, line[0], line[1], CV_RGB(255,0,0), 3, 8 );
        }
#endif
        cvNamedWindow( "Source", 1 );
        cvShowImage( "Source", src );

        cvNamedWindow( "Hough", 1 );
        cvShowImage( "Hough", color_dst );

        cvWaitKey(0);
    }

}

i used this code for “hough transform” in opencv to detect object in a image. and program run without any error. but the result is only a console window appear quickly and disappear quickly. what should i do for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:31:32+00:00Added an answer on June 4, 2026 at 10:31 pm

    That’s some bad logic you got over there:

    • 1st: if argc is bigger or smaller than 2, your main code won’t run, nor will you be notified about it.
    • 2nd: if for any reason cvLoadImage() fails, you will also not be notified about it.

    I suspect one of these 2 things are happening: either you are not calling your program with the right number of parameters, or cvLoadImage() is failing (unable to find the file or the file type is not supported).

    I suggest you add appropriate debugs (printf calls) to see what is really going on.

    EDIT:

    A couple of notes:

    • If your image is being loaded as "qqqq.jpg" and if you are running your program from within Visual Studio, you need to put the image inside the same folder as your source code files (and not in the folder where your .exe is);
    • If you are using Windows and trying to load the image using the full path, don’t forget to escape the slashes: C:\\folder\\qqqq.jpg
    • FYI, argc == 2 implies that you are running your application from the command-line using the format: app.exe param1
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include cv.h #include highgui.h #include <stdio.h> int main(int argc, char* argv[]){ cvNamedWindow(Window1, CV_WINDOW_AUTOSIZE); IplImage*
#include <stdio.h> #include <stdlib.h> int main(int argc,char *argv[]) { system(PAUSE); return 0; } After
#include<math.h> #include<stdio.h> int main() { long i,j[100000],k,l,T,a,n[100000],c,sum=0,m; scanf(%ld\n, &T); for(c=1; c<=T; c++) { n[c]
#include<iostream> #include<cstdio> using namespace std; int main() { int T; char J[100], S[100]; int
#include <stdio.h> #include <string.h> #include <cstdlib> const int KEY=118; int main() { FILE* hOFile
#include <stdio.h> #include <GL/gl.h> #include <GL/glut.h> #define KEY_ESCAPE 27 void display(); void keyboard(unsigned char,int,int);
#include <iostream> #include <fstream> using namespace std; int main() { ifstream stream1(source.txt); string line
#include <iostream> using namespace std; class B { public: int getMsg(int i) { return
I am using this code: #include <stdlib.h> #include <stdio.h> #include <math.h> #include <cv.h> #include
These are includes which I am using #include <opencv2/features2d/features2d.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> #include

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.