Example #1
0
void ofxLibdc::applySettings() {
	if(camera)
		dc1394_capture_stop(camera);
		
	if(use1394b) {
		// assumes you want to run your 1394b camera at 800 Mbps
		dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_1394B);
		dc1394_video_set_iso_speed(camera, DC1394_ISO_SPEED_800);
	} else {
		dc1394_video_set_operation_mode(camera, DC1394_OPERATION_MODE_LEGACY);
		dc1394_video_set_iso_speed(camera, DC1394_ISO_SPEED_400);
	}
		
	dc1394framerate_t framerate;
	if(useFormat7) {
		videoMode = (dc1394video_mode_t) ((int) DC1394_VIDEO_MODE_FORMAT7_0 + format7Mode);
	} else {
		dc1394video_modes_t video_modes;
		dc1394_video_get_supported_modes(camera, &video_modes);
		dc1394color_coding_t coding;
		dc1394color_coding_t targetCoding = getLibdcType(imageType);
		for (int i = 0; i < video_modes.num; i++) {
			if (!dc1394_is_video_mode_scalable(video_modes.modes[i])) {
				dc1394video_mode_t curMode = video_modes.modes[i];
				dc1394_get_color_coding_from_video_mode(camera, curMode, &coding);
				unsigned int curWidth, curHeight;
				dc1394_get_image_size_from_video_mode(camera, curMode, &curWidth, &curHeight);
				if (coding == targetCoding && width == curWidth && height == curHeight) {
					videoMode = curMode;
					break;
				}
			}
			if(i == video_modes.num - 1) {
				ofLog(OF_LOG_ERROR, "Camera does not support target mode.");
				return;
			}
		}
		
		// get fastest framerate
		// todo: make this settable
		dc1394framerates_t framerates;
		dc1394_video_get_supported_framerates(camera, videoMode, &framerates);
		framerate = framerates.framerates[framerates.num - 1];
	}
	
	if(useFormat7) {
		quantizePosition();
		quantizeSize();
		dc1394_format7_set_roi(camera, videoMode, getLibdcType(imageType), DC1394_USE_MAX_AVAIL, left, top, width, height);
		unsigned int curWidth, curHeight;
		dc1394_format7_get_image_size(camera, videoMode, &curWidth, &curHeight);
	} else {
		dc1394_video_set_framerate(camera, framerate);
	}
	
	// contrary to the libdc1394 format7 demo, this should go after the roi setting
	dc1394_video_set_mode(camera, videoMode);
		
	dc1394_capture_setup(camera, OFXLIBDC_BUFFER_SIZE, DC1394_CAPTURE_FLAGS_DEFAULT);
}
Example #2
0
void ofxLibdc::setPosition(unsigned int left, unsigned int top) {
	bool changed = left != this->left || top != this->top; 
	this->left = left;
	this->top = top;
	if(camera && changed) {
		quantizePosition();
		dc1394_format7_set_image_position(camera, videoMode, this->left, this->top);
	}
}
// Create Point Set Continuation block for point set
U3DDataBlockWriter SaveU3D::CreatePointSetContinuationBlock(PointSetSpecificationStruct pointSetGeometry, U3DPointSetInfoStruct pointSetInfo)
{
  MLuint8 signsXYZ;
	MLuint32 diffX;
  MLuint32 diffY;
  MLuint32 diffZ;

  _statusFld->setStringValue("Assembling data for PointSet: " + pointSetInfo.DisplayName + ".");

  U3DDataBlockWriter thisPointSetContinuationBlock;
  thisPointSetContinuationBlock.blockType = U3D_BLOCKTYPE_POINTSETCONTINUATION;

	thisPointSetContinuationBlock.writeString(pointSetInfo.ResourceName);    // Write Point Set Name (9.6.2.2.1)
  thisPointSetContinuationBlock.writeU32(U3D_ReservedZero);                // Write Chain Index (9.6.2.2.2) (shall be zero) 
  thisPointSetContinuationBlock.writeU32(0x00000000);                      // Write Point Resolution Range - Start Resolution (9.6.2.2.3.1) 
  thisPointSetContinuationBlock.writeU32(pointSetInfo.PointCount);         // Write Point Resolution Range - End Resolution (9.6.2.2.3.2) (# of points)

	for (MLuint32 currentPosition = 0; currentPosition < pointSetInfo.PointCount; currentPosition++)
	{
	  MLint32 splitPositionIndex = currentPosition - 1;

	  if (0 == currentPosition) 
    // Special case for first position!
    // No split position and no diff - instead the position itself is written
	  {
	    thisPointSetContinuationBlock.writeCompressedU32(U3DContext_StaticFull + 0x00000001, 0);  // Write Split Position Index (9.6.2.2.4.1)
	  } 
	  else 
	  {
	    thisPointSetContinuationBlock.writeCompressedU32(U3DContext_StaticFull + currentPosition, splitPositionIndex);  // Write Split Position Index (9.6.2.2.4.1)
	  }

	  // Write New Position Info (9.6.2.2.4.2)
	  PositionStruct currentPositionData = pointSetGeometry.positions[currentPosition];
	  PositionStruct predictedPositionData;
	  if (splitPositionIndex >= 0) { predictedPositionData = pointSetGeometry.positions[splitPositionIndex]; }

    Vector3 positionDifferenceVec3 = currentPositionData.position - predictedPositionData.position;

    quantizePosition(positionDifferenceVec3, signsXYZ, diffX, diffY, diffZ);

    thisPointSetContinuationBlock.writeCompressedU8(U3DContext_cPosDiffSign, signsXYZ);          // Write New Position Info - Position Difference Signs (9.6.1.3.4.10.1)
    thisPointSetContinuationBlock.writeCompressedU32(U3DContext_cPosDiffX, diffX);               // Write New Position Info - Position Difference X (9.6.1.3.4.10.2)
    thisPointSetContinuationBlock.writeCompressedU32(U3DContext_cPosDiffY, diffY);               // Write New Position Info - Position Difference Y (9.6.1.3.4.10.3)
    thisPointSetContinuationBlock.writeCompressedU32(U3DContext_cPosDiffZ, diffZ);               // Write New Position Info - Position Difference Z (9.6.1.3.4.10.4)

		MLuint32 newPointCount = 1;  // Always add 1 new point in this version
    MLuint32 newNormalCount = ( (pointSetInfo.NormalCount > 0) ? newPointCount : 0);             // Should be zero -> no normals in this version
		thisPointSetContinuationBlock.writeCompressedU32(U3DContext_cNormlCnt, newNormalCount);      // Write Point Description - New Normal Count (9.6.2.2.4.3) - always 1 normal per point 
      
		// Write New Normal Info (9.6.2.2.4.4) [UNUSED BY ACROBAT]
		for (MLuint32 newNormalIndex = 0; newNormalIndex < newNormalCount; newNormalIndex++) 
    {
		  //Vector3 currentNormalVec3; currentNormalVec3.x = 0; currentNormalVec3.y = 0; currentNormalVec3.z = 0;
		  //Vector3 predictedNormalVec3 = currentNormalVec3;  // Normals are always 0,0,0 in this version
		  Vector3 normalDifferenceVec3;// = currentNormalVec3 - predictedNormalVec3;

      quantizeNormal(normalDifferenceVec3, signsXYZ, diffX, diffY, diffZ);

		  // Write normal at line start
      thisPointSetContinuationBlock.writeCompressedU8(U3DContext_cDiffNormalSign, signsXYZ);   // Write Normal Difference Signs (9.6.2.2.4.4.1)
		  thisPointSetContinuationBlock.writeCompressedU32(U3DContext_cDiffNormalX, diffX);        // Write Normal Difference X (9.6.2.2.4.4.2) 
		  thisPointSetContinuationBlock.writeCompressedU32(U3DContext_cDiffNormalY, diffY);        // Write Normal Difference Y (9.6.2.2.4.4.3)
		  thisPointSetContinuationBlock.writeCompressedU32(U3DContext_cDiffNormalZ, diffZ);        // Write Normal Difference Z (9.6.2.2.4.4.4) 
    }

    thisPointSetContinuationBlock.writeCompressedU32(U3DContext_cPointCnt_cLineCnt_cFaceCnt, newPointCount);  // Write Point Description - New Point Count (9.6.2.2.4.5) 

	  // Write New Point Info (9.6.2.2.4.6)
	  for (MLuint32 newPointInfoNumber = 0; newPointInfoNumber < newPointCount; newPointInfoNumber++) 
    {
	    thisPointSetContinuationBlock.writeCompressedU32(U3DContext_cShading, 0x00000000);                      // Write Shading ID (9.6.2.2.4.6.1)
	    thisPointSetContinuationBlock.writeCompressedU32(U3DContext_cNormlIdx, newPointInfoNumber);             // Write Normal Local Index (9.6.2.2.4.6.2) - Must be written although no normals are used at all in this version!

      // Write no New Point Diffuse Color Coords (9.6.2.2.4.6.3) since it is not supported by this version
      // Write no New Point Specular Color Coords (9.6.2.2.4.6.4) since it is not supported by this version [UNUSED BY ACROBAT]
      // Write no New Point Texture Coords (9.6.2.2.4.6.5) since it is not supported by this version        [UNUSED BY ACROBAT]
	 }

	}  // for (MLuint32 currentPosition = 0...

  return thisPointSetContinuationBlock;
}