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 6249745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:17:43+00:00 2026-05-24T13:17:43+00:00

I’m trying to get some image processing code working in MS VC++ 2010 express.

  • 0

I’m trying to get some image processing code working in MS VC++ 2010 express. The code uses opencv so I’ve downloaded that and installed it. I’ve created a project and added the opencv files to the project. I’ve 2 probs that the compiler can’t open #include <unistd.h> and #include <getopt.h>. Any ideas how to include these headers in my project. Sorry but I’m new to c++ and usually program in android/eclipse. Thanks!

#include <cv.h>
#include <highgui.h>
#include <math.h>
#include <unistd.h>
#include <getopt.h>
#include <iostream>

void sampleImage(const IplImage* arr, float idx0, float idx1, CvScalar& res)
{
  if(idx0<0 || idx1<0 || idx0>(cvGetSize(arr).height-1) || idx1>(cvGetSize(arr).width-1)){
    res.val[0]=0;
    res.val[1]=0;
    res.val[2]=0;
    res.val[3]=0;
    return;
  }
  float idx0_fl=floor(idx0);
  float idx0_cl=ceil(idx0);
  float idx1_fl=floor(idx1);
  float idx1_cl=ceil(idx1);

  CvScalar s1=cvGet2D(arr,(int)idx0_fl,(int)idx1_fl);
  CvScalar s2=cvGet2D(arr,(int)idx0_fl,(int)idx1_cl);
  CvScalar s3=cvGet2D(arr,(int)idx0_cl,(int)idx1_cl);
  CvScalar s4=cvGet2D(arr,(int)idx0_cl,(int)idx1_fl);
  float x = idx0 - idx0_fl;
  float y = idx1 - idx1_fl;
  res.val[0]= s1.val[0]*(1-x)*(1-y) + s2.val[0]*(1-x)*y + s3.val[0]*x*y + s4.val[0]*x*(1-y);
  res.val[1]= s1.val[1]*(1-x)*(1-y) + s2.val[1]*(1-x)*y + s3.val[1]*x*y + s4.val[1]*x*(1-y);
  res.val[2]= s1.val[2]*(1-x)*(1-y) + s2.val[2]*(1-x)*y + s3.val[2]*x*y + s4.val[2]*x*(1-y);
  res.val[3]= s1.val[3]*(1-x)*(1-y) + s2.val[3]*(1-x)*y + s3.val[3]*x*y + s4.val[3]*x*(1-y);
}

float xscale;
float yscale;
float xshift;
float yshift;

float getRadialX(float x,float y,float cx,float cy,float k){
  x = (x*xscale+xshift);
  y = (y*yscale+yshift);
  float res = x+((x-cx)*k*((x-cx)*(x-cx)+(y-cy)*(y-cy)));
  return res;
}

float getRadialY(float x,float y,float cx,float cy,float k){
  x = (x*xscale+xshift);
  y = (y*yscale+yshift);
  float res = y+((y-cy)*k*((x-cx)*(x-cx)+(y-cy)*(y-cy)));
  return res;
}

float thresh = 1;
float calc_shift(float x1,float x2,float cx,float k){
  float x3 = x1+(x2-x1)*0.5;
  float res1 = x1+((x1-cx)*k*((x1-cx)*(x1-cx)));
  float res3 = x3+((x3-cx)*k*((x3-cx)*(x3-cx)));

  //  std::cerr<<"x1: "<<x1<<" - "<<res1<<" x3: "<<x3<<" - "<<res3<<std::endl;

  if(res1>-thresh && res1 < thresh)
    return x1;
  if(res3<0){
    return calc_shift(x3,x2,cx,k);
  }
  else{
    return calc_shift(x1,x3,cx,k);
  }
}

int main(int argc, char** argv)
{
  IplImage* src = cvLoadImage( argv[1], 1 );
  IplImage* dst = cvCreateImage(cvGetSize(src),src->depth,src->nChannels);
  IplImage* dst2 = cvCreateImage(cvGetSize(src),src->depth,src->nChannels);
  float K=atof(argv[3]);
  float centerX=atoi(argv[4]);
  float centerY=atoi(argv[5]);
  int width = cvGetSize(src).width;
  int height = cvGetSize(src).height;

  xshift = calc_shift(0,centerX-1,centerX,K);
  float newcenterX = width-centerX;
  float xshift_2 = calc_shift(0,newcenterX-1,newcenterX,K);

  yshift = calc_shift(0,centerY-1,centerY,K);
  float newcenterY = height-centerY;
  float yshift_2 = calc_shift(0,newcenterY-1,newcenterY,K);
  //  scale = (centerX-xshift)/centerX;
  xscale = (width-xshift-xshift_2)/width;
  yscale = (height-yshift-yshift_2)/height;

  std::cerr<<xshift<<" "<<yshift<<" "<<xscale<<" "<<yscale<<std::endl;
  std::cerr<<cvGetSize(src).height<<std::endl;
  std::cerr<<cvGetSize(src).width<<std::endl;

  for(int j=0;j<cvGetSize(dst).height;j++){
    for(int i=0;i<cvGetSize(dst).width;i++){
      CvScalar s;
      float x = getRadialX((float)i,(float)j,centerX,centerY,K);
      float y = getRadialY((float)i,(float)j,centerX,centerY,K);
      sampleImage(src,y,x,s);
      cvSet2D(dst,j,i,s);

    }
  }
#if 0
  cvNamedWindow( "Source1", 1 );
  cvShowImage( "Source1", dst);
  cvWaitKey(0);
#endif

  cvSaveImage(argv[2],dst,0);

#if 0
  for(int j=0;j<cvGetSize(src).height;j++){
    for(int i=0;i<cvGetSize(src).width;i++){
      CvScalar s;
      sampleImage(src,j+0.25,i+0.25,s);
      cvSet2D(dst,j,i,s);
    }
  }

  cvNamedWindow( "Source1", 1 );
  cvShowImage( "Source1", src);
  cvWaitKey(0);
#endif

}
  • 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-24T13:17:45+00:00Added an answer on May 24, 2026 at 1:17 pm

    Based on a quick look at this source file, you shouldn’t need either of those includes. You definitely don’t need getopt here, as you’re not using the getopt functions it defines. Just remove those includes, and see if things don’t just work.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am trying to loop through a bunch of documents I have to put

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.