Software Archive
Read-only legacy content
17061 Discussions

Interpreting PXCPointF32 coordinates? R200 Person Tracking

Johannes_V_
New Contributor I
180 Views

Hello everybody,

 

i have trouble interpreting the coordinates x, y from a PXCPointF32 Format. What does it mean? It ranges from.. 10^-18 to somewhat ..10^+38.

 

Here is a sample code showing what i currently do:

int main() {
	
	PXCSenseManager *sm = PXCSenseManager::CreateInstance();
	sm->EnableStream(PXCCapture::STREAM_TYPE_COLOR, 640, 480, 30);
	sm->EnableStream(PXCCapture::STREAM_TYPE_DEPTH, 320, 240, 30,PXCCapture::Device::STREAM_OPTION_DEPTH_PRECALCULATE_UVMAP);
	
	pxcStatus sts = sm->EnablePersonTracking();
	PXCPersonTrackingModule *ptm = sm->QueryPersonTracking();
	PXCPersonTrackingConfiguration *ptc = ptm->QueryConfiguration();
	ptc->SetTrackedAngles(PXCPersonTrackingConfiguration::TRACKING_ANGLES_ALL);
	PXCPersonTrackingData *ptData;
	sm->Init();

	
	namedWindow("rgb", 1);
	PXCCapture::Sample *sample;
	Mat rgb, depth;

	while (sm->AcquireFrame(true) >= PXC_STATUS_NO_ERROR)
	{
		//acquire the sample from the camera
		sample = sm->QuerySample();

		//if there is any color sample, convert it to cv::Mat
		if (sample->color) {
			rgb = PXCImage2CVMat(sample->color, PXCImage::PIXEL_FORMAT_RGB24);
		}

		ptData = ptm->QueryOutput(); // get person tracking module output

		pxcI32 persons = ptData->QueryNumberOfPeople();  // how many people are detected

		//iterate over each detected person
		for (pxcI32 i = 0; i < persons; ++i) {
			//get the person itself
			PXCPersonTrackingData::Person *person =  ptData->QueryPersonData(PXCPersonTrackingData::AccessOrderType::ACCESS_ORDER_BY_ID, i);
			PXCPersonTrackingData::PersonTracking *pTrack = person->QueryTracking(); 
			//get person bounding box
			PXCPersonTrackingData::BoundingBox2D personBox = pTrack->Query2DBoundingBox();

			//not really needed, just to clarify
			int centerX = personBox.rect.x;
			int centerY = personBox.rect.y;
			int personWidth = personBox.rect.w;
			int personHeight = personBox.rect.h;
			//make opencv box 
			Rect box = Rect(centerX,centerY,personWidth,personHeight);
			//draw the box
			rectangle(rgb, box, Scalar(255, 0, 0), 3, 8, 0);
			//output to console
			//cout << endl << to_string(centerX) << "/" << to_string(centerY) << " " << personWidth << "x" << personHeight;
			//put ID above the box
			putText(rgb, to_string(pTrack->QueryId()), Point(centerX, centerY), FONT_HERSHEY_PLAIN, 2.0, Scalar(255, 255, 0));

			//now the joints, get them all from the currently selected(iterated) person
			PXCPersonTrackingData::PersonJoints *joints =  ptData->QueryPersonData(PXCPersonTrackingData::AccessOrderType::ACCESS_ORDER_BY_ID, i)->QuerySkeletonJoints();

			pxcI32 nJoints = joints->QueryNumJoints(); 
                         //This is from documentation example, but there is no JointPoint member of PXCPersonTrackingData
			//PXCPersonTrackingData::JointPoint *points = new PXCPersonTrackingData::JointPoint[njoints];
			PXCPersonTrackingData::PersonJoints::SkeletonPoint * points  = new PXCPersonTrackingData::PersonJoints::SkeletonPoint[nJoints];
			joints->QueryJoints(points);
			cout << endl << sizeof(joints) << endl;
			for (int k = 0; k < sizeof(joints); ++k) {
				PXCPointF32 tmp =  points.image;
				
				cout << tmp.x << " , " << tmp.y <<endl;
				circle(rgb, Point(tmp.x, tmp.y), 5, Scalar(255, 125, 50), 3, 8, 0);
				string s = to_string(tmp.x*640) + "\n" + to_string(tmp.y*480);
				putText(rgb, s, Point(10, 400), FONT_HERSHEY_PLAIN, 1.0, Scalar(0, 255, 255), 4, 8, false);
			}
			
			delete[] points;
		}

		//cout << endl << "detecting " << persons << " people" << endl;
		imshow("rgb", rgb);
		char c = waitKey(20); 
		sm->ReleaseFrame();
	}
	
	sm->Release();

	cout <<endl <<"error level : " <<  sts << endl << "should be : " << PXC_STATUS_NO_ERROR << endl;
	system("pause");
	return 0;
}

 

 

 

 

the problem is in line 67. I expected the X and Y coordinates to be integers in range from 0 ... 639  * 0 ... 479 and not a floating point number.

What am i doing wrong?

 

Regards

0 Kudos
0 Replies
Reply