i am writing an opencv program, changing the image color and saving the image with a name given by the user, that name is stored at some variable. I want to use popen to send that file to print.
#include <stdio.h>
#include "cv.h"
#include "highgui.h"
int main (int argc, char ** argv)
{
int p[3];
p[0] = CV_IMWRITE_JPEG_QUALITY;
p[1] = 10;
p[2] = 0;
char name[10];
IplImage* in = cvLoadImage("imagenoise1.jpg",3);
IplImage* gray = cvCreateImage( cvSize(in->width, in->height),IPL_DEPTH_8U, 1 );
cvCvtColor( in, gray, CV_BGR2GRAY );
cvNamedWindow("in", CV_WINDOW_AUTOSIZE );
cvNamedWindow("gray", CV_WINDOW_AUTOSIZE );
cvShowImage("in",in);
cvShowImage("gray",gray);
printf("Con que nombre desea guardar la imagen en escala de grises ( no mas de 9 caracteres ):\n");
scanf("%s", name);
cvSaveImage( name, gray, p );
FILE *pipe = popen("lp name","w");
close(pipe);
cvWaitKey(0);
cvDestroyWindow( "in" );
cvDestroyWindow( "gray" );
cvReleaseImage( &in );
cvReleaseImage( &gray );
return 0;
}
So i am trying to send the specific name i gives before, but nothing seems to work, any idea?, i think i am missing something because send a file that does not exist.