if ( URLDownloadToFileA(NULL,LPCSTR(m_url),LPCSTR(filename),0,NULL) == S_OK ) {
IplImage *img = cvLoadImage(filename, CV_LOAD_IMAGE_COLOR);
//...
}
//if ( URLDownloadToFileA(NULL,LPCSTR(m_url),LPCSTR(filename),0,NULL) == S_OK ) {
IplImage *img = cvLoadImage(/*filename*/m_url, CV_LOAD_IMAGE_COLOR);
//...
//}
#define MAX_JPEG_IMAGE_SIZE 1000000
int jpeg_params[] = { CV_IMWRITE_JPEG_QUALITY, 50, 0 };
CvMat* encodedMat;
IplImage* frame = 0;
CvCapture *capture;
int image_length;
unsigned char jpeg_image[MAX_JPEG_IMAGE_SIZE];
{
cvWaitKey(100);
frame = cvQueryFrame(capture);
if (frame == NULL) {
printf("ERROR %s() Can't query frame from camera.\n", __FUNCTION__);
break;
}
encodedMat = cvEncodeImage(".jpeg", frame, jpeg_params);
if (encodedMat == NULL) {
printf("ERROR %s() Can't encode frame.\n", __FUNCTION__);
break;
}
if (encodedMat->cols > MAX_JPEG_IMAGE_SIZE) {
printf("ERROR %s() Size of encoded image (%d) exceeded maximum buffer size (%d).\n",
__FUNCTION__, encodedMat->cols, MAX_JPEG_IMAGE_SIZE);
break;
}
image_length = encodedMat->cols;
memcpy(jpeg_image, encodedMat->data.ptr, image_length);
cvReleaseMat(&encodedMat);
}
{
{
CvCapture* capture = cvCaptureFromCAM( KAMIND );// где KAMIND индекс камеры в системе
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if(capture == NULL)// Если камер не обнаружено
assert( capture );
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 320);//1280);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT,240);//960);
int counter=0;
char filename[512];
while(true){
// получаем кадр
frame = cvQueryFrame( capture );
// показываем
cvShowImage("Video", frame);
char c = cvWaitKey(33);
if (c == 27) {break;} // нажата ESC
else if(c == 13) { // Enter сохраняем кадр в файл
sprintf(filename, "Image%d.jpg", counter);
printf("[i] capture... %s\n", filename);
cvSaveImage(filename, frame);cvSaveImage(filename, dst);
counter++;}}
// освобождаем ресурсы
cvReleaseCapture( &capture );
cvDestroyWindow("capture");cvDestroyAllWindows();
}