Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not parse declaration at '{' in the code of struct #62

Closed
gjhkael opened this issue Jun 25, 2015 · 5 comments
Closed

Could not parse declaration at '{' in the code of struct #62

gjhkael opened this issue Jun 25, 2015 · 5 comments

Comments

@gjhkael
Copy link

gjhkael commented Jun 25, 2015

there is a error when calling "mvn clean package --projects myproject". I need your help!!!

the maven error :

 Failed to execute goal org.bytedeco:javacpp:0.10:build (generate-sources) on project videoabstraction: Failed to execute JavaCPP Builder: /home/lxy/git/javacpp-presets/videoabstraction/cppbuild/linux-x86_64/include/videoObjectInfo.h:21: Could not parse declaration at '{' -> [Help 1]

the code :

 typedef struct _frameInfo
    {
        int frameNum;
        int moveObjectCount;
        std::vector<cv::Rect> objectList;
        _frameInfo()                           // this line is the num:21
        {
            frameNum = -1;
            moveObjectCount = 0;
        }
        _frameInfo(int num)
        {
            frameNum = num;
            moveObjectCount = 0;
        }
        void addObjectInfo(cv::Rect rect)
        {
            objectList.push_back(rect);
            moveObjectCount++;
        }
    }FrameInfo,*FrameInfoPtr;
@saudet
Copy link
Member

saudet commented Jun 25, 2015

I've tried it here and it works just fine. Make sure to run mvn install on the latest version of the source code: https://github.com/bytedeco/javacpp

@saudet saudet closed this as completed Jun 25, 2015
saudet added a commit to bytedeco/javacpp that referenced this issue Jun 27, 2015
@saudet
Copy link
Member

saudet commented Jun 27, 2015

The actual problematic code is the following:

class VideoObjectInfo
{
public:
typedef struct _frameInfo
{
    int frameNum;//帧编号
    int moveObjectCount;//当前帧中运动目标总个数
    std::vector<int> objectList;//用于存储当前帧中所用运动目标信息
    _frameInfo()                               
    {                                                //num:21
        frameNum = -1; 
        moveObjectCount = 0;
    }
    _frameInfo(int num)
    {
        frameNum = num;
        moveObjectCount = 0;
    }
    void addObjectInfo(int rect)//向帧中添加一个新的运动目标信息
    {
        objectList.push_back(rect);
        moveObjectCount++;
    }
}FrameInfo,*FrameInfoPtr;
};

@saudet saudet added bug and removed question labels Jun 27, 2015
@ConeyLiu
Copy link

this is the head file :

//完成单帧中运动目标信息的提取
//整段视频中运动目标信息的保存、读取功能
#pragma once

#include <fstream>
#include <string>
#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>

class VideoObjectInfo
{
public:
    //继续定义帧结构,用于保存单帧中所有运动目标信息
    typedef struct _frameInfo
    {
        int frameNum;//帧编号
        int moveObjectCount;//当前帧中运动目标总个数
        std::vector<cv::Rect> objectList;//用于存储当前帧中所用运动目标信息
        _frameInfo()
        {
            frameNum = -1;
            moveObjectCount = 0;
        }
        _frameInfo(int num)
        {
            frameNum = num;
            moveObjectCount = 0;
        }
        void addObjectInfo(cv::Rect rect)//向帧中添加一个新的运动目标信息
        {
            objectList.push_back(rect);
            moveObjectCount++;
        }
    }FrameInfo,*FrameInfoPtr;

private:
    int frameCount;//当前视频中帧的总个数
    int dynamicFrameCount;//当前视频动态帧个数
    int staticFrameCount;//当前视频静态帧个数,通过三者,判断当前视频类型
    std::vector<FrameInfoPtr> frameList;//存放所有信息
    std::string videoName;
    std::string startTime;

public:
    VideoObjectInfo();
    VideoObjectInfo(std::string &videoName);
    std::string getVideoTime(std::string & filename);//根据文件绝对路径信息,分析提取视频起始时间信息
    void extractObjectInfo(cv::Mat &foreground,int frameID);
    void extractObjectInfo(cv::Mat & frame,cv::Mat &foreground,int frameID);//提取当前给出的前景图中的前景信息
    void saveObjectInfo(std::string &filename);//将信息保存到系统文件中
    void readObjectInfo(std::string &filename);//从系统文件中读取信息,用于视频的分类,设计时将考虑的内容分添加进来
    int analyzeVideoType();//根据静态帧与动态帧的比例,判定当前帧的视频场景,稀疏0,规律1,稠密

    std::vector<FrameInfoPtr> getFrameList();
    int getDynamicFrameCount();
    std::string getStartTime();
};

and the presets file:

package org.bytedeco.javacpp.presets;

import org.bytedeco.javacpp.annotation.Platform;
import org.bytedeco.javacpp.annotation.Properties;
import org.bytedeco.javacpp.tools.Info;
import org.bytedeco.javacpp.tools.InfoMap;
import org.bytedeco.javacpp.tools.InfoMapper;

/**
 * Created by lxy on 15-6-25.
 */

@Properties( target="org.bytedeco.javacpp.videoObjectInfo",
        value={@Platform(include="<videoObjectInfo.h>",includepath="/usr/local/include/opencv",link="videoabstraction@.so")})
public class videoObjectInfo implements InfoMapper{
    @Override
    public void map(InfoMap infoMap) {
        infoMap.put(new Info("std::String").cast().valueTypes("String"));
        infoMap.put(new Info("cv::Mat").cast().pointerTypes("BytePointer"));
        infoMap.put(new Info("FrameInfoPtr").cast().pointerTypes("Pointer"));
        infoMap.put(new Info("std::vector<FrameInfoPtr>").cast().pointerTypes("Pointer"));
        infoMap.put(new Info("cv::Rect").cast().pointerTypes("BytePointer"));

    }
}

the errors:

/home/lxy/git/javacpp-presets/videoabstraction/target/classes/org/bytedeco/javacpp/jnivideoObjectInfo.cpp:1519:17: error: ‘FrameInfoPtr’ has not been declared there
/home/lxy/git/javacpp-presets/videoabstraction/target/classes/org/bytedeco/javacpp/jnivideoObjectInfo.cpp:1519:29: error: Invalid argument Templates Chapter 1
/home/lxy/git/javacpp-presets/videoabstraction/target/classes/org/bytedeco/javacpp/jnivideoObjectInfo.cpp:1519:29: error: Invalid argument Templates Chapter 2
/home/lxy/git/javacpp-presets/videoabstraction/target/classes/org/bytedeco/javacpp/jnivideoObjectInfo.cpp:1519:36: error: invalid type in declaration before ‘;’ token
/home/lxy/git/javacpp-presets/videoabstraction/target/classes/org/bytedeco/javacpp/jnivideoObjectInfo.cpp:1522:41: error: the type / values of the first argument do not match,
In the 'template <class _Tp, class _Alloc> class std :: vector' template parameter lis
/home/lxy/git/javacpp-presets/videoabstraction/target/classes/org/bytedeco/javacpp/jnivideoObjectInfo.cpp:1522:41: error :   Requires a type, but given 'FrameInfoPtr'
/home/lxy/git/javacpp-presets/videoabstraction/target/classes/org/bytedeco/javacpp/jnivideoObjectInfo.cpp:1522:41: error :   Invalid argument Templates Chapter 2
/home/lxy/git/javacpp-presets/videoabstraction/target/classes/org/bytedeco/javacpp/jnivideoObjectInfo.cpp:1522:43: error: expected primary-expression before ‘)’ token
/home/lxy/git/javacpp-presets/videoabstraction/target/classes/org/bytedeco/javacpp/jnivideoObjectInfo.cpp:1522:44: error: expected ‘;’ before ‘new’

@saudet
Copy link
Member

saudet commented Jun 29, 2015

You're going to need to add something like these two lines to the Parser config file to get this generated properly:

    infoMap.put(new Info("VideoObjectInfo::FrameInfoPtr").valueTypes("VideoObjectInfo.FrameInfo"))
    infoMap.put(new Info("std::vector<VideoObjectInfo::FrameInfoPtr>").pointerTypes("FrameInfoVector").define())

@ConeyLiu
Copy link

The perfect solution for your answer to my question,thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants