Exemplo n.º 1
0
int blobsSetup()
{
	uint8_t c;

	// setup camera mode
	cam_setMode(CAM_MODE1);
 	
#ifdef DA
	// load lut if we've grabbed any frames lately
	if (g_rawFrame.m_pixels)
		cc_loadLut();
#endif

	// if there have been any parameter changes, we should regenerate the LUT (do it regardless)
	g_blobs->m_clut.generateLUT();	
			
	// setup qqueue and M0
	g_qqueue->flush();
	exec_runM0(0);

	// flush serial receive queue
	while(ser_getSerial()->receive(&c, 1));

	g_state = 0; // reset recv state machine
	return 0;
}
Exemplo n.º 2
0
int ptSetup()
{
	// setup camera mode
	cam_setMode(CAM_MODE1);

	// extend range of servos (handled in params)
	// rcs_setLimits(0, -200, 200);	(handled in rcservo params)
	// rcs_setLimits(1, -200, 200);	(handled in rcservo params)

	// Increasing the PWM frequency makes the servos zippier. 
	// Pixy updates at 50 Hz, so a default servo update freq of 50 Hz
	// adds significant latency to the control loop--- increasing to 100 Hz decreases this.
	// Increasing to more than 130 Hz or so creates buzzing, prob not good for the servo.
	// rcs_setFreq(100); (handled in rcservo params)
 
 	ptLoadParams();
	
	g_panLoop.reset();
	g_tiltLoop.reset();

	// load lut if we've grabbed any frames lately
	if (g_rawFrame.m_pixels)
		cc_loadLut();

	// setup qqueue and M0
	g_qqueue->flush();
	exec_runM0(0);

	return 0;
}
void cc_loadParams(void)
{
	int i;
	ColorModel model;
	char id[32], desc[32];

	// set up signatures, load later
	for (i=1; i<=NUM_MODELS; i++)
	{
		sprintf(id, "signature%d", i);
		sprintf(desc, "Color signature %d", i);
		// add if it doesn't exist yet
		prm_add(id, PRM_FLAG_INTERNAL, desc, INTS8(sizeof(ColorModel), &model), END);
	}

	// others -----

	// setup
	prm_add("Max blocks", 0, 
		"Sets the maximum total blocks sent per frame. (default 1000)", UINT16(1000), END);
	prm_add("Max blocks per signature", 0, 
		"Sets the maximum blocks for each color signature sent for each frame. (default 1000)", UINT16(1000), END);
	prm_add("Min block area", 0, 
	"Sets the minimum required area in pixels for a block.  Blocks with less area won't be sent. (default 20)", UINT32(1), END); //TMS: default 20
	prm_add("Min saturation", 0,
		"@c Signature_creation Sets the minimum allowed color saturation for when generating color signatures. Applies during teaching. (default 15.0)", FLT32(15.0), END);
	prm_add("Hue spread", 0,
		"@c Signature_creation Sets how inclusive the color signatures are with respect to hue. Applies during teaching. (default 1.5)", FLT32(1.5), END);
	prm_add("Saturation spread", 0,
		"@c Signature_creation Sets how inclusive the color signatures are with respect to saturation. Applies during teaching. (default 1.5)", FLT32(1.5), END);
	prm_add("CC min saturation", 0,
		"@c Signature_creation Sets the minimum allowed color saturation for when generating color code (CC) signatures. Applies during teaching. (default 15.0)", FLT32(15.0), END);
	prm_add("CC hue spread", 0,
		"@c Signature_creation Sets how inclusive the color code (CC) signatures are with respect to hue. Applies during teaching. (default 3.0)", FLT32(3.0), END);
	prm_add("CC saturation spread", 0,
		"@c Signature_creation Sets how inclusive the color code (CC) signatures are with respect to saturation for color codes. Applies during teaching. (default 50.0)", FLT32(50.0), END);
	prm_add("Color code mode", 0,
		"Sets the color code mode, 0=disabled, 1=enabled, 2=color codes only, 3=mixed (default 1)", INT8(1), END);

	// load
	uint8_t ccMode;
	uint16_t maxBlobs, maxBlobsPerModel;
	uint32_t minArea;

	prm_get("Max blocks", &maxBlobs, END);
	prm_get("Max blocks per signature", &maxBlobsPerModel, END);
	prm_get("Min block area", &minArea, END);
	prm_get("Color code mode", &ccMode, END);
	g_blobs->setParams(maxBlobs, maxBlobsPerModel, minArea, (ColorCodeMode)ccMode);

	cc_loadLut();

}
Exemplo n.º 4
0
int blobsSetup()
{
	// setup camera mode
	cam_setMode(CAM_MODE1);
 	
	// load lut if we've grabbed any frames lately
	if (g_rawFrame.m_pixels)
		cc_loadLut();

	// setup qqueue and M0
	g_qqueue->flush();
	exec_runM0(0);

	return 0;
}
Exemplo n.º 5
0
int chaseSetup()
{
	// setup camera mode
	cam_setMode(CAM_MODE1);

 	chaseLoadParams();
	rcs_setPos(LEFT_AXIS, RCS_CENTER_POS);
	rcs_setPos(RIGHT_AXIS, RCS_CENTER_POS);
	
	// load lut if we've grabbed any frames lately
	if (g_rawFrame.m_pixels)
		cc_loadLut();

	// setup qqueue and M0
	g_qqueue->flush();
	exec_runM0(0);

	return 0;
}
int32_t cc_clearSig(const uint8_t &model)
{
	char id[32];
	ColorModel cmodel;
	int res;

 	if (model<1 || model>NUM_MODELS)
		return -1;

	memset(&cmodel, 0, sizeof(cmodel));

	sprintf(id, "signature%d", model);
	res = prm_set(id, INTS8(sizeof(ColorModel), &cmodel), END);

	// update lut
 	cc_loadLut();

	return res;
}
Exemplo n.º 7
0
int blobsSetup()
{
	uint8_t c;

	// setup camera mode
	cam_setMode(CAM_MODE1);
 	
	// load lut if we've grabbed any frames lately
	if (g_rawFrame.m_pixels)
		cc_loadLut();

	// setup qqueue and M0
	g_qqueue->flush();
	exec_runM0(0);

	// flush serial receive queue
	while(ser_getSerial()->receive(&c, 1));

	return 0;
}
int32_t cc_getRLSFrameChirpFlags(Chirp *chirp, uint8_t renderFlags)
{
	int32_t result;
	uint32_t len, numRls;

	if (g_rawFrame.m_pixels)
		cc_loadLut();

	g_qqueue->flush();

	// figure out prebuf length (we need the prebuf length and the number of runlength segments, but there's a chicken and egg problem...)
	len = Chirp::serialize(chirp, RLS_MEMORY, RLS_MEMORY_SIZE,  HTYPE(0), UINT16(0), UINT16(0), UINTS32_NO_COPY(0), END);

	result = cc_getRLSFrame((uint32_t *)(RLS_MEMORY+len), LUT_MEMORY);
	// copy from IPC memory to RLS_MEMORY
	numRls = g_qqueue->readAll((Qval *)(RLS_MEMORY+len), (RLS_MEMORY_SIZE-len)/sizeof(Qval));
	Chirp::serialize(chirp, RLS_MEMORY, RLS_MEMORY_SIZE,  HTYPE(FOURCC('C','C','Q','1')), HINT8(renderFlags), UINT16(CAM_RES2_WIDTH), UINT16(CAM_RES2_HEIGHT), UINTS32_NO_COPY(numRls), END);
	// send frame, use in-place buffer
	chirp->useBuffer(RLS_MEMORY, len+numRls*4);

	return result;
}
int32_t cc_clearAllSig()
{
	char id[32];
	uint8_t model;
	ColorModel cmodel;
	int res; 

	memset(&cmodel, 0, sizeof(cmodel));

   	for (model=1; model<=NUM_MODELS; model++)
	{
		sprintf(id, "signature%d", model);
		res = prm_set(id, INTS8(sizeof(ColorModel), &cmodel), END);
		if (res<0)
			return res;			
	}

	// update lut
 	cc_loadLut();

	return 0;
}