title: opencv c++, cvSaveImage not saving when program is executed from php
body: <p>I am programming a face detection app using opencv c++(eclipse) on os X (lion).  The program loads an image file, detects the faces, and then saves each individual face into separate files.  The program works 100% as it is from a command line or in eclipse.  I then wrote a php script for file upload so someone can upload a jpg or png file then the script saves the photo with a unique file name.  Then at the end of the php script I have it execute the face detection program.</p>
  
  <p>I am not sure what the difference is in running the application from a command line and having a php call the application to run.  Here is my code below.</p>
  
  <p>function in c++:</p>
  
  <pre><code>    cvNamedWindow ("ROI", CV_WINDOW_AUTOSIZE);
      cvCvtColor( clone, gray, CV_RGB2GRAY );
  
  
      cvSetImageROI ( gray, *r);
  
      //// * rectangle  = cvGetImageROI ( clone );
      *r = cvGetImageROI ( gray );
      cvShowImage ("ROI", gray);
  
      k++;
      char *name=0;
  
      name=(char*) calloc(512, 1);
      sprintf(name, "/Users/jason/Sites/jason.dev/images/proc_images/Image%d.png", k);
      cvSaveImage(name, gray);
  </code></pre>
  
  <p>php script:</p>
  
  <pre><code>&lt;?php
  mysql_connect("127.0.0.1:3306","xxxx","xxxx");
  mysql_select_db("opencv_development");
  
  
  $uploaddir = "images/";
  $file = basename($_FILES['uploadedfile']['name']);
  $stamp = date("YmdHis");
  $random = rand(0, 999);
  $newName = $uploaddir . $stamp . $random . $file;
  
  
  if ($_FILES['uploadedfile']['size']&gt; 300000)     //Limiting image at 300K
  {
  exit("Your file is too large."); 
  }
  
  
  
  if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $newName)) {
  echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
  " has been uploaded";
  } else{
  echo "There was an error uploading the file, please try again!";
  }
  
  mysql_query("INSERT INTO recv_img (photo_name) VALUES ('$newName')");
  
  
  shell_exec("./opencv '$newName'");
  
  ?&gt;
  </code></pre>
  
  <p>As I said above, if I run the application from terminal then it outputs the individual face files. When it is executed from the php script, the image loads into the application, it does the face detection, but it does not save the individual face files.</p>
  
  <p>Let me know if any further information is needed or if I was not clear about something.  Any help is greatly appreciated!</p>