예제 #1
0
//-----------------------------------------------------------------------------
TEST_F(Test_Parser_Preprocessor, Basic_define)
{
#if 0
	// <Test> 関数形式マクロの定義 (引数無し)
	{
		const char* code = "#define AAA() 1";
		Preprocess(code);
		m_fileCache->outputMacroMap;
	}
	// <Test> 関数形式マクロの定義 (引数1つ)
	{
		const char* code = "#define AAA(x) x+1";
		Preprocess(code);
	}
	// <Test> 関数形式マクロの定義 (引数2つ以上)
	{
		const char* code = "#define AAA(x, y) x+y";
		Preprocess(code);
	}
	// <Test> 関数形式マクロの定義 (可変長引数)
	{
		const char* code = "#define AAA(...) __VA_ARGS__";
		Preprocess(code);
	}
	// <Test> 関数形式マクロの定義 (引数1つ + 可変長引数)
	{
		const char* code = "#define AAA(x, ...) x+__VA_ARGS__";
		Preprocess(code);
	}
#endif
}
예제 #2
0
//-----------------------------------------------------------------------------
TEST_F(Test_Parser_Preprocessor, Basic_ifndef)
{
	// <Test> 無効領域
	{
		const char* code =
			"#define AAA\n"
			"#ifndef AAAB\n"
			"1\n"
			"#endif\n";
		Preprocess(code);

		// 数値 1 は有効領域
		ASSERT_EQ(CommonTokenType::ArithmeticLiteral, m_tokens->GetAt(10).GetCommonType());
		ASSERT_EQ(true, m_tokens->GetAt(10).IsValid());
	}
	// <Test> 有効領域
	{
		const char* code =
			"#define AAA\n"
			"#ifndef AAA\n"
			"1\n"
			"#endif\n";
		Preprocess(code);

		// 数値 1 は無効領域
		ASSERT_EQ(CommonTokenType::ArithmeticLiteral, m_tokens->GetAt(10).GetCommonType());
		ASSERT_EQ(false, m_tokens->GetAt(10).IsValid());
	}
}
예제 #3
0
//-----------------------------------------------------------------------------
TEST_F(Test_Parser_Preprocessor, Basic)
{
	{
		const char* code = "#define AAA";
		Preprocess(code);
	}
	{
		const char* code = "#define AAA 1";
		Preprocess(code);
	}
	{
		const char* code = "#define AAA 1 ";
		Preprocess(code);
	}
}
void
avtPreprocessorModule::InputIsReady(void)
{
    debug1 << "Starting preprocessing for " << GetType() << endl;
    Preprocess();
    debug1 << "Done preprocessing for " << GetType() << endl;
}
void CHandGestureRecognitionSystemDlg::OnTimer(UINT_PTR nIDEvent)
{
    // TODO: Add your message handler code here and/or call default
    if(!InitCameraAndImage())
        return;
    // play image camera
    PlayImage(image_camera, IDC_IMAGE_CAMERA, rect_image_camera);
    // process
    image_preprocess = Preprocess(image_camera, image_preprocess);
    // segment
    image_segment = HandSegment(image_preprocess, image_segment);
    PlayImage(image_segment, IDC_IMAGE_SEGMENT, rect_image_segment);
    // feature detect
    image_feature = FeatureDetect(image_segment, image_feature);
    PlayImage(image_feature, IDC_IMAGE_FEATURE, rect_image_feature);
    // recognition
    image_recognition = Recognition(image_feature, image_recognition);
    PlayImage(image_recognition, IDC_IMAGE_RECOGNITION, rect_image_recognition);
#ifdef _DEBUG
    TRACE("image_camera channel = %d\n", image_camera.channels());
    TRACE("image_segment channel = %d\n", image_segment.channels());
    TRACE("image_feature channel = %d\n", image_feature.channels());
    TRACE("image_recognition channel = %d\n", image_recognition.channels());
#endif
    CDialogEx::OnTimer(nIDEvent);
}
예제 #6
0
vector<float> CaffeMobile::Forward(const cv::Mat &img) {
  CHECK(!img.empty()) << "img should not be empty";

  Blob<float> *input_layer = net_->input_blobs()[0];
  input_layer->Reshape(1, num_channels_, input_geometry_.height,
                       input_geometry_.width);
  /* Forward dimension change to all layers. */
  net_->Reshape();

  vector<cv::Mat> input_channels;
  WrapInputLayer(&input_channels);

  Preprocess(img, &input_channels);

  clock_t t_start = clock();
  net_->Forward();
  clock_t t_end = clock();
  LOG(INFO) << "Forwarding time: " << 1000.0 * (t_end - t_start) / CLOCKS_PER_SEC
            << " ms.";

  /* Copy the output layer to a vector */
  Blob<float> *output_layer = net_->output_blobs()[0];
  const float *begin = output_layer->cpu_data();
  const float *end = begin + output_layer->channels();
  return vector<float>(begin, end);
}
예제 #7
0
bool TMixedDescriptorDatabase::FindFileContainingExtension(const Stroka& containing_type, int field_number,
        NProtoBuf::FileDescriptorProto* output) {
    TInfo info(output);
    return output != NULL
           && DoFindFileContainingExtension(containing_type, field_number, info)
           && Preprocess(info);
}
예제 #8
0
//-----------------------------------------------------------------------------
TEST_F(Test_Parser_Preprocessor, Unit_include)
{
	// <Test> include ファイル内のマクロ定義が取り出せる。
	//{
	//	const char* code =
	//		"#include \"test.h\"\n"
	//		"#ifdef TEST\n"
	//		"1\n"
	//		"#endif";
	//	Preprocess(code);
	//	ASSERT_EQ(true, m_tokens->GetAt(10).IsValid());
	//}
	// <Test> 同じ include ファイルが複数回 include され、それぞれ定義マクロが異なる場合
	{
		const char* code =
			"#include \"IncludeTest1.h\"\n"
			"#ifdef CCC\n"
			"1\n"
			"#endif\n"
			"#ifdef BBB\n"
			"1\n"
			"#endif\n"
			"#define AAA\n"
			"#include \"IncludeTest1.h\"\n"
			"#ifdef BBB\n"
			"1\n"
			"#endif";
		Preprocess(code);
		ASSERT_EQ(true, m_tokens->GetAt(10).IsValid());
		ASSERT_EQ(false, m_tokens->GetAt(20).IsValid());
		ASSERT_EQ(true, m_tokens->GetAt(40).IsValid());		// AAA が定義されたので .h 内で BBB が定義される
	}
}
예제 #9
0
//-------------------------- Main function --------------------------
void Tracker::Track(const Mat &next_frame) {
  CHECK_NOTNULL(detector_);

  cv::Mat frame = next_frame.clone();
  frame = Preprocess(frame);

  if (bgs_ != nullptr) {
    // Segment foreground.
    bgs_->NextFrame(frame);
    frame = bgs_->GetForeground();
  }

  if (filter_ != nullptr) {
    // Predict new position and feed it to the detector.
    filter_->Predict();
    Mat predicted_x = filter_->predicted_x();
    detector_->set_state(StateMatToRect(predicted_x));
  }

  // Detect new state.
  detector_->NextFrame(frame);
  detector_->Detect();

  // Get measurement from core tracker.
  state_ = detector_->state();

  if (filter_ != nullptr) {
    // Feed measurement to Kalman filter and retrieve new state.
    filter_->Update(StateRectToMat(state_));
    state_ = StateMatToRect(filter_->x());
  }

  Postprocess();
}
예제 #10
0
파일: FAO.cpp 프로젝트: OkabeRintarou/syl
Token Scanner::GetNextToken()
{
	Preprocess();
	if (file_.eof()){
		return Token(TokenType::TOKEN_END_OF_FILE, -1);
	}

	if (std::isdigit(cur_char_)){
		return HandleInteger();
	}
	else if (IsOperator()){
		char op = cur_char_;
		Advance();
		return Token(TokenType::TOKEN_OPERATION, op);
	}
	else if (IsLeftParam()){
		Advance();
		return Token(TokenType::TOKEN_LEFT_PARAM, '(');
	}
	else if (IsRightParam()){
		Advance();
		return Token(TokenType::TOKEN_RIGHT_PARAM, ')');
	}

	return Token();
}
예제 #11
0
int  KnuthMorrisPratt(char* Text, int TextSize, int Start, 
                      char* Pattern, int PatternSize )
{
    int i = Start;
    int j = 0;
    int Position = -1;
    
    int* Border = (int*)calloc( PatternSize + 1, sizeof( int ) );

    Preprocess( Pattern, PatternSize, Border );

    while ( i < TextSize )
    {
        while ( j >= 0 && Text[i] != Pattern[j] )
            j = Border[j];

        i++;
        j++;

        if ( j == PatternSize )
        {
            Position = i - j;
            break;
        }
    }

    free( Border );
    return Position;
}
예제 #12
0
int main()
{
  int i, n1, n2, w;
  
#ifndef ONLINE_JUDGE
  freopen("input.txt", "rt", stdin);
#endif
  scanf("%d", &N);

  for (i = 0; i < N - 1; i++)
  {
    scanf("%d %d %d", &n1, &n2, &w);
    A[n1].push_back(node(w, n2));
    A[n2].push_back(node(w, n1));

    Flag[n1] = Flag[n2] = false;
  }

  Preprocess();

  // query-urile
  scanf("%d", &M);

  for (i = 0; i < M; i++)
  {
    scanf("%d %d", &n1, &n2);
    //printf("lca(%d, %d) = %d\n", n1, n2, lca(n1, n2));
    printf("%d\n", W[n1] + W[n2] - 2 * W[lca(n1, n2)]);
  }

	return 0;
}
예제 #13
0
bool GenericObjectDetector::Run(const cv::Mat& color_img, vector<ImgWin>& det_wins)
{
	if( !Preprocess(color_img) )
		return false;


	return true;
}
예제 #14
0
//-----------------------------------------------------------------------------
TEST_F(Test_Parser_Preprocessor, Basic_empty)
{
	// <Test> 空のディレクティブ (#だけ)
	{
		const char* code =
			"#\n"	// 末尾がNewLine
			"#";	// 末尾がEOF
		Preprocess(code);
		// 無視されるので、エラーや警告が無ければOK
	}
}
예제 #15
0
int main()
{
	int n;
	Preprocess();
	for (;;) {
		scanf("%d", &n);
		if (n == 0) break;
		printf("%lld\n", Fib[n]);
	}
	return 0;
}
예제 #16
0
QTSS_Error QTSSRawFileModuleDispatch(QTSS_Role inRole, QTSS_RoleParamPtr inParams)
{
    switch (inRole)
    {
        case QTSS_Register_Role:
            return Register(&inParams->regParams);
        case QTSS_RTSPPreProcessor_Role:
            return Preprocess(&inParams->rtspPreProcessorParams);
    }
    return QTSS_NoErr;
}
예제 #17
0
bool SirenTextParser::ParseFile(const FileIdRef& fileId)
{
	HeapString text = FileSystem::Instance().ReadAllText(fileId);

	if (text.IsEmpty())
	{
		Log::FormatError("Cannot find file:{}", fileId.Name);
		return false;
	}
	Preprocess(text);
	StringRef proto = text;
	return Parse(proto);
}
예제 #18
0
int OIFReader::LoadBatch(int index)
{
   int result = -1;
   if (index>=0 && index<(int)m_batch_list.size())
   {
      m_path_name = m_batch_list[index];
      Preprocess();
      result = index;
      m_cur_batch = result;
   }
   else
      result = -1;

   return result;
}
예제 #19
0
const char* CvFilePath::Find( const char* filename, char* buffer ) const
{
    char path0[_MAX_PATH + 1];
    int len = Preprocess( filename, path0 );
    int folder_len = 0;
    const char* folder = First( folder_len );
    char* name_only = 0;
    char* name = path0;
    FILE* f = 0;

    if( len < 0 )
        return 0;

    do
    {
        if( folder_len + len <= _MAX_PATH )
        {
            memcpy( buffer, folder, folder_len );
            strcpy( buffer + folder_len, name );

            f = fopen( buffer, "rb" );
            if( f )
                break;
        }

        if( name != name_only )
        {
            name_only = strrchr( path0, '/' );
            if( !name_only )
                name_only = path0;
            else
                name_only++;
            len = strlen( name_only );
            name = name_only;
        }
    }
    while( (folder = Next( folder, folder_len )) != 0 );

    filename = 0;

    if( f )
    {
        filename = (const char*)buffer;
        fclose(f);
    }

    return filename;
}
예제 #20
0
파일: Classifier.cpp 프로젝트: mahaben/test
std::vector<float> Classifier::Predict(const cv::Mat& img)
{
    Blob<float>* input_layer = net_->input_blobs()[0];
    input_layer->Reshape(1, 1, input_geometry_.height, input_geometry_.width);
    /* Forward dimension change to all layers. */
    net_->Reshape();
    std::vector<cv::Mat> input_channels;
    WrapInputLayer(&input_channels);
    Preprocess(img, &input_channels);
    net_->ForwardPrefilled();
    /* Copy the output layer to a std::vector */
    Blob<float>* output_layer = net_->output_blobs()[0];
    const float* begin = output_layer->cpu_data();
    const float* end = begin + output_layer->channels();
    return std::vector<float>(begin, end);
}
예제 #21
0
파일: scanner.c 프로젝트: pmprog/cc65
static int SkipWhite (void)
/* Skip white space in the input stream, reading and preprocessing new lines
** if necessary. Return 0 if end of file is reached, return 1 otherwise.
*/
{
    while (1) {
        while (CurC == '\0') {
            if (NextLine () == 0) {
                return 0;
            }
            Preprocess ();
        }
        if (IsSpace (CurC)) {
            NextChar ();
        } else {
            return 1;
        }
    }
}
예제 #22
0
int main(int argc, char **argv)
{
	ParametersType *Parameters;
	MatrixDataType *MatrixData;
	FemStructsType *FemStructs;
	FemFunctionsType *FemFunctions;
	FemOtherFunctionsType *FemOtherFunctions;
	struct timespec Start, End;
	double Preprocess_Time, Process_Time, Postprocess_Time;


	/* ******************************************************* Preprocess ****************************************************** */
	clock_gettime(CLOCK_MONOTONIC, &Start);
	Preprocess(argc, argv, &Parameters, &MatrixData, &FemStructs, &FemFunctions, &FemOtherFunctions);
	clock_gettime(CLOCK_MONOTONIC, &End);
	Preprocess_Time = End.tv_sec - Start.tv_sec + 1e-9*(End.tv_nsec - Start.tv_nsec);
	/* ************************************************************************************************************************* */

	/* ******************************************************** Process ******************************************************** */
	clock_gettime(CLOCK_MONOTONIC, &Start);
	Process(Parameters, MatrixData, FemStructs, FemFunctions, FemOtherFunctions);
	clock_gettime(CLOCK_MONOTONIC, &End);
	Process_Time = End.tv_sec - Start.tv_sec + 1e-9*(End.tv_nsec - Start.tv_nsec);
	/* ************************************************************************************************************************* */

	/* ******************************************************* Postprocess ***************************************************** */

	clock_gettime(CLOCK_MONOTONIC, &Start);
	Postprocess(Parameters, MatrixData, FemStructs, FemFunctions, FemOtherFunctions);
	clock_gettime(CLOCK_MONOTONIC, &End);
	Postprocess_Time = End.tv_sec - Start.tv_sec + 1e-9*(End.tv_nsec - Start.tv_nsec);

	/* ************************************************************************************************************************* */

	/* ******************************************************* Total Time ****************************************************** */
	calculateTime(Preprocess_Time, Process_Time, Postprocess_Time, Parameters);
	/* ************************************************************************************************************************* */

	free(Parameters);
	
	return 0;
}
예제 #23
0
//-----------------------------------------------------------------------------
TEST_F(Test_Parser_Preprocessor, Unit_pragma_once)
{
	// <Test> #pragma once
	{
		const char* code =
			"#include \"pragma_once.h\"\n"
			"#ifdef BBB\n"
			"1\n"
			"#endif\n"
			"#define AAA"
			"#include \"pragma_once.h\"\n"
			"#ifdef BBB\n"
			"1\n"
			"#endif";
		Preprocess(code);
		ASSERT_EQ(true, m_tokens->GetAt(10).IsValid());	// 1 は有効領域
		ASSERT_EQ(true, m_tokens->GetAt(29).IsValid());	// 1 は有効領域
		
	}
}
예제 #24
0
bool Parser::Load(const String & filename)
{
    File * fp = File::Create(pathName, File::OPEN|File::READ);
	if (!fp)
	{
		Logger::Error("Failed to open PVR texture: %s", pathName.c_str());
		return 0;
	}
	textFileInitialSize = fp->GetSize();
	textFile = new char[fileSize];
	uint32 dataRead = fp->Read(textFile, textFileInitialSize);
    DVASSERT(dataRead == textFileInitialSize);
    
    Preprocess();
    
    
    SafeDeleteArray(textFile);
    SafeRelease(fp);
    
}
void ENetSegmenter::Predict(const cv::Mat& in_image_mat, cv::Mat& out_segmented)
{
	caffe::Blob<float>* input_layer = net_->input_blobs()[0];
	input_layer->Reshape(1, num_channels_, input_geometry_.height,
			input_geometry_.width);
	/* Forward dimension change to all layers. */
	net_->Reshape();

	std::vector<cv::Mat> input_channels;
	WrapInputLayer(&input_channels);

	Preprocess(in_image_mat, &input_channels);

	net_->Forward();

	/* Copy the output layer to a std::vector */
	caffe::Blob<float>* output_layer = net_->output_blobs()[0];

	int width = output_layer->width();
	int height = output_layer->height();
	int channels = output_layer->channels();

	// compute argmax
	cv::Mat class_each_row(channels, width * height, CV_32FC1,
			const_cast<float *>(output_layer->cpu_data()));
	class_each_row = class_each_row.t(); // transpose to make each row with all probabilities
	cv::Point maxId;    // point [x,y] values for index of max
	double maxValue;    // the holy max value itself
	cv::Mat prediction_map(height, width, CV_8UC1);
	for (int i = 0; i < class_each_row.rows; i++)
	{
		minMaxLoc(class_each_row.row(i), 0, &maxValue, 0, &maxId);
		prediction_map.at<uchar>(i) = maxId.x;
	}

	out_segmented = Visualization(prediction_map, lookuptable_file_);

	cv::resize(out_segmented, out_segmented, cv::Size(in_image_mat.cols, in_image_mat.rows));


}
예제 #26
0
파일: _SSD.cpp 프로젝트: yankailab/OpenKAI
std::vector<vector<float> > _SSD::detect(Frame* pFrame)
{
    vector<vector<float> > detections;

    if(pFrame==NULL)return detections;
    if(pFrame->empty())return detections;

    Blob<float>* input_layer = net_->input_blobs()[0];
    input_layer->Reshape(1, num_channels_, input_geometry_.height, input_geometry_.width);
    /* Forward dimension change to all layers. */
    net_->Reshape();

    std::vector<cv::cuda::GpuMat> input_channels;
    WrapInputLayer(&input_channels);
    Preprocess(*pFrame->getGMat(), &input_channels);

//	std::vector<cv::Mat> input_channels;
//	WrapInputLayer(&input_channels);
//	Preprocess(*pFrame->getCMat(), &input_channels);

    net_->Forward();

    /* Copy the output layer to a std::vector */
    Blob<float>* result_blob = net_->output_blobs()[0];
    const float* result = result_blob->cpu_data();
    const int num_det = result_blob->height();
    for (int k = 0; k < num_det; ++k)
    {
        if (result[0] == -1)
        {
            // Skip invalid detection.
            result += 7;
            continue;
        }
        vector<float> detection(result, result + 7);
        detections.push_back(detection);
        result += 7;
    }

    return detections;
}
예제 #27
0
static kNode *ParseSource(KonohaContext *kctx, kNameSpace *ns, const char *script, size_t len)
{
	KBuffer wb;
	KLIB KBuffer_Init(&(kctx->stack->cwb), &wb);
	KLIB KBuffer_Write(kctx, &wb, "(", 1);
	KLIB KBuffer_Write(kctx, &wb, script, len);
	KLIB KBuffer_Write(kctx, &wb, ")", 1);

	KTokenSeq tokens = {ns, KGetParserContext(kctx)->preparedTokenList};
	KTokenSeq_Push(kctx, tokens);
	const char *buf = KLIB KBuffer_text(kctx, &wb, EnsureZero);
	SUGAR Tokenize(kctx, ns, buf, 0, 0, tokens.tokenList);
	KTokenSeq_End(kctx, tokens);

	KTokenSeq step2 = {ns, tokens.tokenList, kArray_size(tokens.tokenList)};
	SUGAR Preprocess(kctx, ns, RangeTokenSeq(tokens), NULL, step2.tokenList);
	KTokenSeq_End(kctx, step2);
	kNode *newexpr = SUGAR ParseNewNode(kctx, ns, step2.tokenList, &step2.beginIdx, step2.endIdx, 0, NULL);
	KTokenSeq_Pop(kctx, tokens);
	KLIB KBuffer_Free(&wb);
	return newexpr;
}
예제 #28
0
bool CBC_EAN8::Encode(const CFX_WideStringC& contents,
                      bool isDevice,
                      int32_t& e) {
  if (contents.IsEmpty()) {
    e = BCExceptionNoContents;
    return false;
  }
  BCFORMAT format = BCFORMAT_EAN_8;
  int32_t outWidth = 0;
  int32_t outHeight = 0;
  CFX_WideString encodeContents = Preprocess(contents);
  CFX_ByteString byteString = encodeContents.UTF8Encode();
  m_renderContents = encodeContents;
  uint8_t* data = static_cast<CBC_OnedEAN8Writer*>(m_pBCWriter.get())
                      ->Encode(byteString, format, outWidth, outHeight, e);
  BC_EXCEPTION_CHECK_ReturnValue(e, false);
  static_cast<CBC_OneDimWriter*>(m_pBCWriter.get())
      ->RenderResult(encodeContents.AsStringC(), data, outWidth, isDevice, e);
  FX_Free(data);
  BC_EXCEPTION_CHECK_ReturnValue(e, false);
  return true;
}
예제 #29
0
int DichotomySearch::Search(int * array, int element, int size) {
    int **addit_array = Preprocess(array, size);
    int leftborder, rightborder, middle, temp;
    leftborder = 0;
    rightborder = size - 1;
    while (1) {
        middle = (leftborder + rightborder) / 2;
        if (element < addit_array[middle][1]) {
            rightborder = middle - 1;
        } else if (element > addit_array[middle][1]) {
            leftborder = middle + 1;
        } else {
            temp = addit_array[middle][0];
            DeleteMemory(addit_array, size);
            return temp;
        }
        if (leftborder > rightborder) {
            DeleteMemory(addit_array, size);
            return  -1;
        }
    }
}
예제 #30
0
bool  CvFilePath::Add( const char* path )
{
    char buffer[_MAX_PATH + 1];
    int len = Preprocess( path, buffer );

    if( len < 0 )
        return false;

    if( m_len + len + 3 // +1 for one more ';',
                        // another +1 for possible additional '/',
                        // and the last +1 is for '\0'
                      > m_maxsize )
    {
        int new_size = (m_len + len + 3 + 1023) & -1024;
        char* new_path = new char[new_size];

        if( m_path )
        {
            memcpy( new_path, m_path, m_len );
            delete[] m_path;
        }

        m_path = new_path;
        m_maxsize = new_size;
    }

    m_path[m_len++] = ';';
    memcpy( m_path + m_len, buffer, len );
    m_len += len;

    if( m_path[m_len] != '/' )
        m_path[m_len++] = '/';

    m_path[m_len] = '\0'; // '\0' is not counted in m_len.

    return true;
}