|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#4
|
||||
|
||||
|
Re: Getting an ODROID Up and Running
Setting up everything is the hard part, well more boring than hard, in my mind, so congrats!
(I realize that I sent you this nearly identical message as a pm in response to yours, but then only you can learn) So, assuming everything is up and running properly, this simple c code should be able to display what the webcam is seeing, and when you hit the escape key, it will exit the code and save the last frame where ever the executable is. Also, it will give you the fps. #include <opencv/cv.h> #include <opencv/highgui.h> #include <stdio.h> #include <time.h> #include "timer.h" #include <math.h> #include <iostream> #include <iomanip> #include <fstream> #include <sys/stat.h> #include <sys/types.h> #include <QtNetwork> using namespace std; #define IMAGE_HEIGHT 480 #define IMAGE_WIDTH 640 IplImage* img = cvCreateImage(cvSize(IMAGE_WIDTH,IMAGE_HEIGHT),16, 3); char c; char str[50]; CvFont font; int main() { cvNamedWindow("Image", CV_WINDOW_AUTOSIZE); cvMoveWindow("Image", 750, 10); cvInitFont(&font, CV_FONT_HERSHEY_COMPLEX_SMALL, 0.75, 0.75, 0, 1, CV_AA); double frame_time_ms; double ave_frame_time_ms; DECLARE_TIMING(RGB_Timer); START_TIMING(RGB_Timer); CvCapture* capture0 = cvCreateCameraCapture( 0 ); assert( capture0 ); while(1) { img = cvQueryFrame( capture0 ); // Write FPS on output image STOP_TIMING(RGB_Timer); frame_time_ms = GET_TIMING(RGB_Timer); ave_frame_time_ms = (GET_AVERAGE_TIMING(RGB_Timer)); if (frame_time_ms > 0 && ave_frame_time_ms > 0) { sprintf(str, "Current FPS = %.1f", 1000/frame_time_ms); cvPutText(img, str, cvPoint(10, 40), &font, cvScalar(255, 0, 255, 0)); sprintf(str, "Average FPS = %.1f", ave_frame_time_ms); cvPutText(img, str, cvPoint(10, 20), &font, cvScalar(255, 0, 255, 0)); c = cvWaitKey(10); if (c==27) //escape key pressed { break; } } START_TIMING(RGB_Timer); cvShowImage("Image", img); } cvSaveImage("./raw.png", img); cvDestroyAllWindows(); } for a udp packet(with qt): QUdpSocket udpSocket; declare this,and include the header #include <QtNetwork> then, once you have done calculated a variable you want to send the cRIO (distance, x rotation, etc..): QByteArray datagram = QByteArray::number(distance) + " " + QByteArray::number(Xrot) + " " + QByteArray::number((double)TargetType) + " "; udpSocket.writeDatagram(datagram.data(), datagram.size(), QHostAddress(0x0A110602), 80); note: make sure both parties have the same ip address, and port 80 is what we used due to other ones not working. Hope this helped! *side note* not being able to see the thread to which you are replying is rather annoying when you can't remember exactly what was addressed. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|