![]() |
Comprehensive help for camera code
for(UINT32 x = 0; x < particles->size(); x++)
{ ParticleAnalysisReport& par = (*particles)[x]; if(par.center_mass_x_normalized > 0) { //right } if(par.center_mass_x_normalized < 0) { //left } } This is a part of an example of tracking code. I do not understand the purpose of the for, or why (*particles)[x] isn't just (*particles) Is particles->size(); returning the number of particles or something? If so, wouldn't the code make the robot cycle through aiming at the different targets? |
Re: Comprehensive help for camera code
It would indeed attempt to drive towards each particle in turn. I forget if I posted that particular code snippet, but what you'd probably want would be something like this, where you select a favourite particle. For example, here's code that selects the biggest particle:
Code:
ParticleAnalysisReport biggest = {0};For your syntax question: particles is a pointer to a vector<ParticleAnalysisReport>. Therefore, to call member functions on it like size(), you need to use the arrow operator. To call the square-bracket operator, you need to indirect it using the * first to get yourself a non-pointer vector<ParticleAnalysisReport>. particles->size() tells you how many particles there are in the list of particles. |
| All times are GMT -5. The time now is 17:41. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi