Oppure

Loading
20/10/08 13:19
feddur
Salve, vorrei compilare questo codice:

hci.iastate.edu/575x/…

// C++ includes.
#include <iostream>
 
// OpenCV includes.
#include <cv.h>
#include <highgui.h>
 
void printCamResolution(CvCapture* camera)
{
	std::cout << std::endl;
	std::cout << "Camera Capture Resolution:" << std::endl;
	std::cout << "=================" << std::endl;
	std::cout << "Video width: " << cvGetCaptureProperty(
		camera, CV_CAP_PROP_FRAME_WIDTH) << std::endl;
	std::cout << "Video height: " << cvGetCaptureProperty(
		camera, CV_CAP_PROP_FRAME_HEIGHT) << std::endl;
	std::cout << std::endl;
}
 
int main(int argc, char* argv[])
{
	// Tell OpenCV to capture data from a camera.
	CvCapture* camera = cvCaptureFromCAM(0);
 
	// Print the camera's properties.
	printCamResolution(camera);
 
	// Create a window with the given name (displayed at the top of the
	// window).  Also, we'll make it automatically resize to whatever content
	// it displays.
	cvNamedWindow("My Window", CV_WINDOW_AUTOSIZE);
 
	// Loop forever until the user quits.
	while(1)
	{
		// This will return the code of the pressed key or -1 if
		// nothing was pressed before 10 ms elapsed.
		int keyCode = cvWaitKey(10);
 
		if ('c' == (char)keyCode)
		{
			// The user pressed 'c' (for 'capture').
 
			// Get the latest image from the camera.  This
			// image should NOT be released manually.
			IplImage* image = cvQueryFrame(camera);
 
			// Make the image show up in the named window.
			cvShowImage("My Window", image);
 
			// Save the image to a file.
			static int imageCount = 0;
			char filename[32];
			sprintf(filename, "image%d.png", imageCount);
			cvSaveImage(filename, image);
			++imageCount;
		}
		else if(keyCode >= 0)
		{
			// A non-capture key was pressed, so end the loop.
			break;
		}
	}
 
	// Destroy the capture object and the window.
	cvReleaseCapture(&camera);
	cvDestroyWindow("My Window");
 
	return 0;
}


solo che ho dei problemi nel trovare i file <cv.h>
e <highgui.h>
come posso fare?
aaa
20/10/08 14:43
gioser
devi scaricare la lireria OpenCV e i relativi file h

sourceforge.net/project/…

Ciao :)
aaa
20/10/08 17:25
feddur
fatto.. ma mi da questi errori...

Compilatore: Default compiler
Building Makefile: "C:\Documents and Settings\Fede\Desktop\C++ includes\Makefile.win"
Esecuzione di  make clean
rm -f main.o  Progetto1.exe

g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"   

main.cpp:5:16: cv.h: No such file or directory

main.cpp:6:21: highgui.h: No such file or directory
main.cpp:8: error: stray '' in program
main.cpp:8: error: expected init-declarator before numeric constant
main.cpp:8: error: expected `,' or `;' before numeric constant
main.cpp:8: error: expected constructor, destructor, or type conversion before '*' token
main.cpp:8: error: expected `,' or `;' before '*' token
main.cpp:13: error: stray '' in program
main.cpp:15: error: stray '' in program
main.cpp:20: error: stray '' in program
main.cpp:20: error: expected init-declarator before numeric constant
main.cpp:20: error: expected `,' or `;' before numeric constant
main.cpp:20: error: expected unqualified-id before "char"
main.cpp:20: error: expected `,' or `;' before "char"
main.cpp:23: error: stray '' in program
main.cpp:26: error: stray '' in program
main.cpp:31: error: stray '' in program

main.cpp:34: error: stray '' in program
main.cpp:38: error: stray '' in program
main.cpp:40: error: stray '' in program
main.cpp:40: error: stray '' in program
main.cpp:46: error: stray '' in program
main.cpp:49: error: stray '' in program
main.cpp:54: error: stray '' in program
main.cpp:55: error: stray '' in program
main.cpp:58: error: stray '' in program
main.cpp:66: error: stray '' in program
main.cpp:67: error: stray '' in program

make.exe: *** [main.o] Error 1

Esecuzione terminata

Ultima modifica effettuata da feddur 20/10/08 17:30
aaa
21/10/08 6:52
gioser
devi dire al compilatore dove hai messo i file h in modo che possa trovarli. :)
aaa
21/10/08 17:50
feddur
Postato originariamente da gioser:

devi dire al compilatore dove hai messo i file h in modo che possa trovarli. :)


sì. li ho messi copme parametri.
uso DEV-C++
opzioni progetto -> parametri
ma non va.. :s
aaa
22/10/08 5:22
munkaka
prova a copiarle nella stessa cartella dei file h di devc++
aaa