use of class template vector requires template arguments

“head code”

  
#pragma once  
  
#include "ofMain.h"  
#include "ofxOpenCv.h"  
#include "ofxKinect.h"  
#include "ofxDelaunay.h"  
#include <vector>  
  
  
class testApp : public ofBaseApp{  
	public:  
		void setup();  
		void update();  
		void draw();  
        ofxKinect kinect;  
		void keyPressed  (int key);  
		void keyReleased(int key);  
		void mouseMoved(int x, int y );  
		void mouseDragged(int x, int y, int button);  
		void mousePressed(int x, int y, int button);  
		void mouseReleased(int x, int y, int button);  
		void windowResized(int w, int h);  
		void dragEvent(ofDragInfo dragInfo);  
		void gotMessage(ofMessage msg);  
    ofEasyCam easyCam;  
private:  
    ofMesh mesh;	// ofVboMesh  
   vector < vector > points;  
    vector < vector > colors;  
    vector < vector > indexs;  
};  
  

i have a problem with “vector”, error “cuse of class template vector requires template arguments” what can it be? what template argumnes and where i must write it?

i now that ther is in C++.

what is in your testApp? i think you get that error because it’s not defined as a type.
as it is, you can:

  
vector <ofVec2f> points   

or

  
vector <ofPoint> points  

but what exactly do you want to do?

  
  
//// update ////  
  
//clear  
mesh.clear();  
points.clear();  
colors.clear();  
indexs.clear();  
  
int step = int(5 + int(scaledVol*15));  
int total = 0;  
for (int j = 0; j < kinect.height; j+=step)  
{  
    vector temppoints;  
    vector tempcolors;  
    points.push_back(temppoints);  
    colors.push_back(tempcolors);  
      
    for (int i = 0; i < kinect.width; i+=step)  
    {  
        float distance = kinect.getDistanceAt(i, j);  
        if(distance>50 && distance<1000)  
        {  
            ofVec3f tempPoint;  
            ofColor tempColor;  
              
            tempPoint = ofVec3f(i, j, distance*-2.0 );  
            tempColor = ofColor(kinect.getColorAt(i,j));  
              
            points[j/step].push_back(tempPoint);  
            colors[j/step].push_back(tempColor);  
              
            total++;  
        }else{  
            ofVec3f tempPoint2;  
            ofColor tempColor2;  
            tempPoint2 = ofVec3f(i,j,0);	  
            tempColor2 = ofColor(0);  
            points[j/step].push_back(tempPoint2);  
            colors[j/step].push_back(tempColor2);  
        }  
    }  
}  
  
  
int ind = 0;  
for (int m = 0; m < kinect.height; m+=step)  
{  
    vector tempindexs;  
    indexs.push_back(tempindexs);  
      
    for (int n = 0; n < kinect.width; n+=step)  
    {  
        if(points[m/step][n/step].z != 0){  
//          cout << points[m][n] << endl;  
            mesh.addColor(colors[m/step][n/step]);  
            mesh.addVertex(points[m/step][n/step]);  
              
            indexs[m/step].push_back(ind);  
            ind++;  
        }else{  
            indexs[m/step].push_back(-1);  
        }  
    }  
}  
  
  
  
  
int W = int(kinect.width/step);  
for (int b = 0; b < kinect.height-step; b+=step){  
    for (int a = 0; a < kinect.width-1; a+=step)  
    {  
        if( (indexs[int(b/step)][int(a/step)]!=-1 && indexs[int(b/step)][int(a/step+1)]!=-1) && (indexs[int(b/step+1)][int(a/step+1)]!=-1 && indexs[int(b/step+1)][int(a/step)]!=-1) ){  
              
            mesh.addTriangle(indexs[int(b/step)][int(a/step)],indexs[int(b/step)][int(a/step+1)],indexs[int(b/step+1)][int(a/step+1)]);  
            mesh.addTriangle(indexs[int(b/step)][int(a/step)],indexs[int(b/step+1)][int(a/step+1)],indexs[int(b/step+1)][int(a/step)]);  
        }  
    }  
}  
//// draw ////  
  
mesh.setMode(OF_PRIMITIVE_TRIANGLES);  
glLineWidth(int(LINE_WEIGHT));  
mesh.drawWireframe();  
  

I will try in this way:

  
//in testApp.h  
    vector < ofVec3f > points;    
    vector < ofColor > colors;    
    vector < int > indexs;   
  
  

  
  
///update  
  
    vector <ofVec3f> temppoints;    
    vector < ofColor> tempcolors;  
      
       vector <int> tempindexs;   
  
  
  

i’m tried this before, and i have this errors:
no viable conversion from "vector to ‘const value_type’ (aka 'const ofVec3f)
and
No member named ‘push_back’ in ‘ofVec3f’

usually for me vector < ofVec3f> works fine for me in Ubuntu12.04 64bit. Try also to add a

  
  
///testApp.h  
using namespace std;  
  

and std::vector instead of only vector

but where do you receive that error exactly? at what line? because reading the code i have the suspect that what i suggest to you in the previous topic do nothing.

has more sense this:

  
//// update ////  
  
//clear  
mesh.clear();  
points.clear();  
colors.clear();  
indexs.clear();  
  
int step = int(5 + int(scaledVol*15));  
int total = 0;  
for (int j = 0; j < kinect.height; j+=step)  
{  
    ofVec3f temppoints;  
    ofColor tempcolors;  
    points.push_back(temppoints);  
    colors.push_back(tempcolors);  
      
    for (int i = 0; i < kinect.width; i+=step)  
    {  
        float distance = kinect.getDistanceAt(i, j);  
        if(distance>50 && distance<1000)  
        {  
            ofVec3f tempPoint;  
            ofColor tempColor;  
              
            tempPoint = ofVec3f(i, j, distance*-2.0 );  
            tempColor = ofColor(kinect.getColorAt(i,j));  
              
            points[j/step].push_back(tempPoint);  
            colors[j/step].push_back(tempColor);  
              
            total++;  
        }else{  
            ofVec3f tempPoint2;  
            ofColor tempColor2;  
            tempPoint2 = ofVec3f(i,j,0);	  
            tempColor2 = ofColor(0);  
            points[j/step].push_back(tempPoint2);  
            colors[j/step].push_back(tempColor2);  
        }  
    }  
}  
  
  
int ind = 0;  
for (int m = 0; m < kinect.height; m+=step)  
{  
    int tempindexs;  
    indexs.push_back(tempindexs);  
      
    for (int n = 0; n < kinect.width; n+=step)  
    {  
        if(points[m/step][n/step].z != 0){  
//          cout << points[m][n] << endl;  
            mesh.addColor(colors[m/step][n/step]);  
            mesh.addVertex(points[m/step][n/step]);  
              
            indexs[m/step].push_back(ind);  
            ind++;  
        }else{  
            indexs[m/step].push_back(-1);  
        }  
    }  
}  
  
  
  
  
int W = int(kinect.width/step);  
for (int b = 0; b < kinect.height-step; b+=step){  
    for (int a = 0; a < kinect.width-1; a+=step)  
    {  
        if( (indexs[int(b/step)][int(a/step)]!=-1 && indexs[int(b/step)][int(a/step+1)]!=-1) && (indexs[int(b/step+1)][int(a/step+1)]!=-1 && indexs[int(b/step+1)][int(a/step)]!=-1) ){  
              
            mesh.addTriangle(indexs[int(b/step)][int(a/step)],indexs[int(b/step)][int(a/step+1)],indexs[int(b/step+1)][int(a/step+1)]);  
            mesh.addTriangle(indexs[int(b/step)][int(a/step)],indexs[int(b/step+1)][int(a/step+1)],indexs[int(b/step+1)][int(a/step)]);  
        }  
    }  
}  
//// draw ////  
  
mesh.setMode(OF_PRIMITIVE_TRIANGLES);  
glLineWidth(int(LINE_WEIGHT));  
mesh.drawWireframe();  
  

points[j/step].push_back(tempPoint); - No member named ‘push_back’ in ‘ofVec3f’

colors[j/step].push_back(tempColor); -No member named ‘push_back’ in ‘ofColor_’

points[j/step].push_back(tempPoint2); - No member named ‘push_back’ in ‘ofVec3f’

colors[j/step].push_back(tempColor2); -No member named ‘push_back’ in ‘ofColor_’

indexs[m/step].push_back(ind); - member reference base type ‘int’ is not a structure union

indexs[m/step].push_back(-1); - member reference base type ‘int’ is not a structure union

if(points[m/step][n/step].z != 0){ - member reference base type ‘float’ is not structure of union

i’m took this code here (http://blog.rettuce.com/mediaart/kinect-of-delaunay/). the first code with point cloud work’s, with second how u see i have problems. but i need the working this code

i looked at the blog. i can’t understand anything, sorry. google translate is very bad in this case… but what i can say is that for me

  
  
vector < vector > points;    
    vector < vector > colors;    
    vector < vector > indexs;   
  

this is wrong because you can make a vector of a vector but you must defined what type of vector.

  
  
vector <vector <ofVec3f>> points;  
vector <vector<ofColor>> colors;  
vector<vector<int>>indexs;  
  

also i don’t know if the all the code is posted in the blog and if could be others relevant and important sections or errors like the above.
let me know if this help a bit, i’m also learning to use the ofxKinect!

maybe you can also ask an advice to the author of the article in the blog…

thx!!!
u are my hero!!!
everything working!
thx again

happy that you solved! good luck with Openframeworks!

Hi Guys,

I am also trying to hack at that same piece of code… struggling to get it working.

Can somebody post the resolved piece of code?

Cheers!

hi @oliverellmers you can find that code in my github repo : https://github.com/kalwalt/OFexamples/tree/master/delaunayKinect .
tell me if you find some issue and report in the OF forum . Thanks