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

  • Home
  • SEARCH
  • 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 3227470
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:34:42+00:00 2026-05-17T16:34:42+00:00

I am trying to write this simple image modifier program in c++ with opencv

  • 0

I am trying to write this simple image modifier program in c++ with opencv on netbeans. I am using ubuntu 10.04. Everytime I try to run or compile it, it returns the below errors. I have opencv configured in the linker and the additional tools. What is going wrong?

include stdlib.h  
include stdio.h  
include math.h  
include cv.h  
include highgui.h  
int main(int argc, char *argv[])  
{  
  IplImage* img = 0;  
  int height,width,step,channels;  
  uchar *data;  
  int i,j,k;  
  if(argc<2){  
    printf("Usage: main <image-file-name>\n\7");  
    exit(0);  
  }  
  // load an image  
  img=cvLoadImage(argv[1]);  
  if(!img){  
    printf("Could not load image file: %s\n",argv[1]);  
    exit(0);  
  }  
  // get the image data  
  height    = img->height;  
  width     = img->width;  
  step      = img->widthStep;  
  channels  = img->nChannels;  
  data      = (uchar *)img->imageData;  
  printf("Processing a %dx%d image with %d channels\n",height,width,channels);  
  // create a window  
  cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);  
  cvMoveWindow("mainWin", 100, 100);  
  // invert the image  
  for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++)  
    data[i*step+j*channels+k]=255-data[i*step+j*channels+k];  
  // show the image  
  cvShowImage("mainWin", img );  
  // wait for a key  
  cvWaitKey(0);  
  // release the image  
  cvReleaseImage(&img );  
  return 0;  
}  

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf  
make[1]: Entering directory `/home/kevin/NetBeansProjects/CppApplication_4'  
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/cppapplication_4  
make[2]: Entering directory `/home/kevin/NetBeansProjects/CppApplication_4'  
mkdir -p build/Debug/GNU-Linux-x86  
rm -f build/Debug/GNU-Linux-x86/main.o.d  
g++    -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/  main.o main.cpp  
main.cpp:4:16: warning: cv.h: No such file or directory  
main.cpp:5:21: warning: highgui.h: No such file or directory  
main.cpp: In function ‘int main(int, char**)’:  
main.cpp:10: error: ‘IplImage’ was not declared in this scope  
main.cpp:10: error: ‘img’ was not declared in this scope  
main.cpp:12: error: ‘uchar’ was not declared in this scope  
main.cpp:12: error: ‘data’ was not declared in this scope  
main.cpp:21: error: ‘cvLoadImage’ was not declared in this scope  
main.cpp:32: error: expected primary-expression before ‘)’ token  
main.cpp:32: error: expected ‘;’ before ‘img’  
main.cpp:36: error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope  
main.cpp:36: error: ‘cvNamedWindow’ was not declared in this scope  
main.cpp:37: error: ‘cvMoveWindow’ was not declared in this scope  
main.cpp:44: error: ‘cvShowImage’ was not declared in this scope  
main.cpp:47: error: ‘cvWaitKey’ was not declared in this scope  
main.cpp:50: error: ‘cvReleaseImage’ was not declared in this scope  
make[2]: *** [build/Debug/GNU-Linux-x86/main.o] Error 1  
make[1]: *** [.build-conf] Error 2  
make: *** [.build-impl] Error 2  
make[2]: Leaving directory `/home/kevin/NetBeansProjects/CppApplication_4'  
make[1]: Leaving directory `/home/kevin/NetBeansProjects/CppApplication_4'  

BUILD FAILED (exit value 2, total time: 115ms)  

EDIT:
Sorry for the massive jumble

  • 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-05-17T16:34:43+00:00Added an answer on May 17, 2026 at 4:34 pm

    Alright mister, this is your compilation line right here:

    g++    -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/  main.o main.cpp
    

    When you include headers using <>:

    #include <cv.h>  
    #include <highgui.h>  
    

    the compiler will search those files on the default include path, which is usually: /usr/include

    So, knowing that opencv doesn’t install its developments files on this directory, I must suggest you to find them. IF opencv is correctly installed on the system, the command pkg-config --cflags opencv is going to tell you where they are. Go ahead, try it. You could also execute pkg-config --libs opencv to find the libraries that you must add to the compilation.

    To summarize everything, if you open up a terminal and cd to the directory where your source code is, the command below might compile your project IF you have opencv correctly installed.

    g++ -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/  main.o main.cpp `pkg-config --cflags opencv` `pkg-config --libs opencv`
    

    EDIT:

    You know what? I just paste some code (opencv/camera) here (let’s call it funcam.cpp). You can use it to test if OpenCV is installed and compiles stuff on your system. You can compile it with:

    g++ funcam.cpp -o funcam `pkg-config --cflags opencv` `pkg-config --libs opencv`
    

    If it works, you must figure out how to configure Netbeans. If it doesn’t, you need to properly install OpenCV.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out how to write this function: template <typename Bound> Bound::result_type
I could probably write this myself, but the specific way I'm trying to accomplish
I'm trying to write a python script that packages our software. This script needs
This is more of a syntax question I'm trying to write a store procedure
I hope this question is not a RTFM one. I am trying to write
I was trying to understand something with pointers, so I wrote this code: #include
I'm trying write a query to find records which don't have a matching record
Trying to write a PowerShell cmdlet that will mute the sound at start, unless
I'm trying to write a regex function that will identify and replace a single
I'm trying to write a blog post which includes a code segment inside a

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.