Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
// cvdemo3.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include"cv.h"#include"highgui.h"#include"cvaux.h"# include"stdlib.h"short _stdcall Inp32(short PortAddress);void _stdcall Out32(short PortAddress, short data);//grey screen+cvLoadImageint _tmain(int argc, _TCHAR* argv[]){ /* const char *c="image001"; IplImage *hw=cvLoadImage( "image001.jpg" ); */ static CvMemStorage* storage = 0; //capturing from cam CvCapture* capture=cvCaptureFromCAM(0); cvWaitKey(0); //tsting if frame was captured or not if(!cvGrabFrame(capture)) {printf("could not capture"); _sleep(2000); exit(0); } printf("captured\n"); storage = cvCreateMemStorage(0); //cvMoveWindow("Hello World", 186, 56); while(1) { //capturing frame cvNamedWindow("Hello World", CV_WINDOW_AUTOSIZE); IplImage *hw=0; hw=cvQueryFrame(capture); double y=cvGetCaptureProperty(capture,5); int height1=hw->height; int width1=hw->width; //cvClearMemStorage(storage); CvScalar s; for(int i=0;i<height1;i++) { for(int j=0;j<width1;j++) { s=cvGet2D(hw,i,j); if(s.val[0]>=140 && s.val[1]>=140 && s.val[2]>=140) s.val[2]=0; s.val[0]=0; s.val[1]=0;//video loop if(s.val[2]<120) s.val[2]=0; else s.val[2]=255; cvSet2D(hw,i,j,s); } } float xcounter,ycounter,xpixel,ypixel; xpixel=0; ypixel=0; xcounter=0; ycounter=0; //finding centre of gravity... for(float i=0;i<height1;i++) { for(float j=0;j<width1;j++) { s=cvGet2D(hw,i,j); if(s.val[2]>120) { xcounter++; ycounter++; xpixel+=j; ypixel+=i; } } } printf("height=%d,width=%d centre of gravity x=%f,y=%f,FPS=%e\n,",height1,width1,xpixel/xcounter,ypixel/ycounter,y); if(xpixel/xcounter<178) { Out32(0x378,255); } else Out32(0x378,0); //display the image in the container cvCircle(hw, cvPoint(xpixel/xcounter,ypixel/ycounter), 10, cvScalar(0,255,0), 1); cvShowImage("Hello World", hw); int c=cvWaitKey(10); if((char)c==27) break; //cvReleaseImage(&hw); } cvDestroyWindow("Hello World"); cvReleaseCapture(&capture); /*//declare for the height and width of the image int height = 620;int width = 440; //specify the point to place the text CvPoint pt = cvPoint( height/4, width/2 ); //Create an 8 bit, 3 plane image IplImage* hw = cvCreateImage(cvSize(height, width), 8, 3); //Clearing the Image cvSet(hw,cvScalar(0,0,0)); //initialize the font CvFont font; cvInitFont( &font, CV_FONT_HERSHEY_COMPLEX,1.0, 1.0, 0, 1, CV_AA); //place the text on the image using the font cvPutText(hw, "Welcome To OpenCV", pt, &font, CV_RGB(150, 0, 150) ); //create the window container cvNamedWindow("Hello World", 0); //display the image in the container cvShowImage("Hello World", hw); //hold the output windows cvWaitKey(0); return 0;*/ }
although i personally thinkcmucam is wate of money but its v gud for the beginners in image processing...basiclly but if u put a little effort u can do more than wat cmucam can do wth opencv and a smal webcam...which is way cheaper but yes alittle diffcult to implement ...
what i do is i do the processing in my pc and send serial commands or parallel commands via wireless to mcu...whose jobis jst to read these commands and control the motors which leads to a much faster processing and response than cmu cam...in my view i save a lot of money and also can gain a lot of knowledge by using opencv as i implement sum higher and more complex algorithms like fae recognition...blob tracking...etc etc etc which in any mcu will take much much time to process...so i alwayz opt for the pc to process any kinda image processing elements...
agreed...but ... processing algos like face detection....motion tracking....is an overkill for any microcontroller...so its better if they are not done in it...and i guess if u use computers then the robot remains autonomous...coz only the program is running and nothing else and remember the mcu is noting but a processor at heart and our computer is the same too...tll date i havent seen any competitions who have denied that u cant use a computer for image processing on ur robot....unless offcourse started by some dumb ppl...
lol and wats not original in not using the laptop for doing image processing ...if they ban rf then use bluetooth ..there are no limitations..i still think processing images on the computer is a way better choice than unecessarily wasting money on the cmu cam...but then its still my own perspective..urs will dffer..
agreed...but ... processing algos like face detection....motion tracking....is an overkill for any microcontroller...so its better if they are not done in it...
lets face it...for any normal competition ...there is no need in spending so much money for a 200mhz mcu...thats what iam exactly saying doing it on a laptop and communication via wireles is a much cheaper and more permanent solutio ...let the algo be anything
lol ...not practical...i can gurantee that i can do more things with the laptp and a webcam than any other cmucam or watever cam can do...and wat kinda limitations are u talking abt...i havent seen any competition which puts such a kinda limitation where u cant use any laptops for image processing.....huh...it would be illogical...even i love challenges...but i need fast processing and instantaneous response...tell me which mcu can do it better than a processor which runs at 2 ghz with 2gb of ddr3 ram .... look at the possibilities ..i can implement more cmplex algos,more better image processing modules and can still expect to get much faster processing.. these modules are required if u want ur robot to be bang on target...i dont want to sacrifice the accuracy and efficiency of my robot for any kinda self processing camera...and why the hell are we fighting...i love this way of mage processing and u love urs...its our different perspective...no need to fight over it..
People you are hijacking this thread!My outlook on itWhen you want it all embedded you can use a CMUcam when you have the luxury of having a laptop always near the robot , then use the wireless method Please make a new thread to continue the conversation .
ok ok, we not fighting, it's an argument