예제 #1
0
//Funcao que salva o frame em uma imagem ppm (posteriormente manipular imagem)
void save_frame(AVFrame * pFrame, int width, int height, int iFrame) 
{
	FILE *pFile;
	char szFilename[32];
	int  y, k;

	// Abre arquivo
	sprintf(szFilename, "../images/frame%d.ppm", iFrame);
	pFile=fopen(szFilename, "wb");
	if(pFile==NULL)
	return;

	// Escreve cabeçalho
	fprintf(pFile, "P6\n%d %d\n255\n", width, height);

	// Escreve os pixels em um arquivo ppm
	for(y = 0; y < height; y++)
	{
		for (k = 0; k < 3 * width; k += 3)
			//Aplicando meu filtro de tons de cinza :P
			gray_filter((pFrame->data[0] + y*pFrame->linesize[0]) + k);

		fwrite(pFrame->data[0]+y*pFrame->linesize[0], 1, width*3, pFile);
	}
	// Fecha arquivo
	fclose(pFile);
}
예제 #2
0
void filter_video(AVFrame * pFrame, int width, int height)
{
	int  y, k;
	//Aplicando meu filtro de tons de cinza :P

	#pragma omp parallel shared(pFrame) private(y, k)
	{
		// std::cout << omp_get_thread_num() << ":" << omp_get_num_threads() << std::endl;
		#pragma omp for
		for(y = 0; y < height; y++)
			for (k = 0; k < 3 * width; k += 3)
			{
				gray_filter((pFrame->data[0] + y*pFrame->linesize[0] + k));
			}
	}
}
예제 #3
0
//tick_idx 0...3
static e_int32 one_slip(laser_sick_t* ls, e_int32 tick_idx, scan_data_t * pdata,
		e_int32 data_offset, e_uint32 data_num, e_int32 type) {

	point_gray_t* pgray;
	point_polar_t *ppoint;
	int k, cheight;

	ppoint = ((point_polar_t*) ls->points_polar->mem) + tick_idx;
	pgray = ((point_gray_t*) ls->points_gray->mem) + tick_idx;

	cheight = ls->height / ls->interlace_v;
	if (e_check(data_num != cheight && data_num+1 != cheight, "#ERROR# 点数个数与要求的不一致!\n")) {
		DMSG(
				(STDOUT,"#ERROR# 点数个数多一个?不可能 data_num[%u] ls->height[%u]\n", (unsigned int)data_num,(unsigned int)ls->height/ls->interlace_v));
		return E_ERROR;
	}

	if (!type) {
		for (k = data_num - 1; k >= 0; --k) {
			ppoint->distance = pdata->range_measurements[data_offset + k];
			ppoint->angle_v = pdata->angle_measurements[data_offset + k];
			ppoint->angle_h = pdata->h_angle;

#if HACK_PNT_ANGLE_H
			ppoint->angle_h += ppoint->angle_v * ls->angle_dif_per_degree;
#endif

			ppoint->intensity = intensity_filter(
					pdata->echo_measurements[data_offset + k]);
			pgray->gray = gray_filter(
					pdata->echo_measurements[data_offset + k]);

			if (ppoint->distance <= 0.0000005) {
//				DMSG((STDOUT,"I"));
#ifdef HACK_INVALID_DATA
				(*ppoint) = *(ppoint - ls->interlace_v);
				(*pgray) = *(pgray - ls->interlace_v);
#endif
			}

			if (ppoint->distance > 22 || ppoint->intensity > 700)
				DMSG(
						(STDOUT,"[%d]\t%f\t%f\t%f\t%u\n",k, ppoint->distance,ppoint->angle_h,ppoint->angle_v,(unsigned int)ppoint->intensity));

			ppoint += ls->interlace_v;
			pgray += ls->interlace_v;
		} // end for
	} else {
#define SHIFT_NUM 0
		//补一行
		if (ls->active_sectors.left && ls->active_sectors.right
				&& cheight == data_num + 1) {
			ppoint += SHIFT_NUM + 1;
			pgray += SHIFT_NUM + 1;
		}

		for (k = 0; k < data_num - SHIFT_NUM; ++k) {
			ppoint->distance = pdata->range_measurements[data_offset + k];
			ppoint->angle_v = pdata->angle_measurements[data_offset + k];
			ppoint->angle_h = pdata->h_angle;
#if HACK_PNT_ANGLE_H
			ppoint->angle_h += ppoint->angle_v * ls->angle_dif_per_degree;
#endif
			ppoint->intensity = intensity_filter(
					pdata->echo_measurements[data_offset + k]);
			pgray->gray = gray_filter(
					pdata->echo_measurements[data_offset + k]);
			if (ppoint->distance <= 0.0000005) {

//				DMSG((STDOUT,"|"));
#ifdef HACK_INVALID_DATA
				(*ppoint) = *(ppoint - ls->interlace_v);
				(*pgray) = *(pgray - ls->interlace_v);
#endif
			}
			if (ppoint->distance > 20 || ppoint->intensity > 700)
				DMSG(
						(STDOUT,"[%d]\t%f\t%f\t%f\t%u\n",k, ppoint->distance,ppoint->angle_h,ppoint->angle_v,(unsigned int)ppoint->intensity));
			ppoint += ls->interlace_v;
			pgray += ls->interlace_v;
		} // end for
	}

	return E_OK;
}