C++ C++;抽象错误 解决方案
我在这里发布解决方案,这样你就不必一直滚动到底。另一个用户为此问题向存储库添加了修复程序/修补程序。修复程序当前不稳定,因此您需要安装此项目的不稳定版本:C++ C++;抽象错误 解决方案,c++,abstract-class,C++,Abstract Class,我在这里发布解决方案,这样你就不必一直滚动到底。另一个用户为此问题向存储库添加了修复程序/修补程序。修复程序当前不稳定,因此您需要安装此项目的不稳定版本: $ git clone https://github.com/avin2/SensorKinect $ cd SensorKinect $ git checkout unstable 问题: 我正试图为我的一个爱好项目手工编译SensorKinect。/RedistMaker Arm的输出超出了30k SOF字符限制,因此我为好奇的人添加了
$ git clone https://github.com/avin2/SensorKinect
$ cd SensorKinect
$ git checkout unstable
问题:
我正试图为我的一个爱好项目手工编译SensorKinect
。/RedistMaker Arm
的输出超出了30k SOF字符限制,因此我为好奇的人添加了。我提取了“重要”部分,并将其添加到下面:
错误
出现摘要
错误的文件是,下面是代码本身:
XnSensorDepthGenerator.cpp
- 当这不起作用时,我试图从
- 当这不起作用时,我从中复制了
和XnSensorGenerator.cpp
XnSensorDepthGenerator.cpp
SensorKinect
,所以我尝试了同样的想法,但使用了一个用于Linux的x86二进制文件;没有成功
此时,我要找出一个新的攻击计划。看起来像是一个老问题,很久以前在不同版本的代码库中修复过:
看起来像是一个老问题,很久以前在不同版本的代码库中修复过:
似乎发生的是基类
XnSensorGenerator
定义了一个纯虚拟函数XnStatus getpixelcordinationsinviewpoint(ProductionNode&other、XnUInt32 x、XnUInt32 y、XnUInt32&altX、XnUInt32&altY)代码>,这意味着每个派生类都必须实现它。但是,XnSensorDepthGenerator
似乎没有它的定义(至少在您介绍的代码中没有)。您可能可以创建一个伪方法,返回默认构造的XnStatus
?@AndyG。我是根据您的建议开始的,当我在其中查找GetPixelCoordinatesInViewPoint
时,什么也没找到。这可能是问题的一部分吗?是的,这似乎是问题的一部分。我注意到你在拉“不稳定”的树枝。也许你应该拉主人。它可能更稳定。请用详细信息更新主要帖子。@Jacksonkr您是否将GetPixelCoordinatesInViewPoint
声明添加到XnSensorDepthGenerator.h
以及XnSensorGenerator.h
中?似乎发生的事情是基类XnSensorGenerator
定义了一个纯虚拟函数XnStatus GetPixelCoordinatedInviewPoint(生产节点和其他、XnUInt32 x、XnUInt32 y、XnUInt32和altX、XnUInt32和altY)代码>,这意味着每个派生类都必须实现它。但是,XnSensorDepthGenerator
似乎没有它的定义(至少在您介绍的代码中没有)。您可能可以创建一个伪方法,返回默认构造的XnStatus
?@AndyG。我是根据您的建议开始的,当我在其中查找GetPixelCoordinatesInViewPoint
时,什么也没找到。这可能是问题的一部分吗?是的,这似乎是问题的一部分。我注意到你在拉“不稳定”的树枝。也许你应该拉主人。它可能更稳定。请用详细信息更新主要帖子。@Jacksonkr您是否将GetPixelCoordinateInViewPoint
声明添加到XnSensorDepthGenerator.h
以及XnSensorGenerator.h
中?我今天早些时候发现了这个补丁,因为我不知道如何修补我的git克隆决定手工修改。修复程序的编辑器对空格/制表符进行了大量更改,因此我看到了许多绿线,并注意到它们很琐碎。不幸的是,这导致我丢失了添加的标题。如何使用命令行将此修补程序应用于克隆?我找到了一种方法,即git
。我还没有弄清楚如何应用一个特定的补丁,但当我这样做的时候,我会将它添加到我的OP中。我今天早些时候发现了这个补丁,因为我不知道如何修补我的git克隆
,我决定手动进行更改。修复程序的编辑器对空格/制表符进行了大量更改,因此我看到了许多绿线,并注意到它们很琐碎。不幸的是,这导致我丢失了添加的标题。如何使用命令行将此修补程序应用于克隆?我找到了一种方法,即git
。我还没有弄清楚如何应用一个特定的补丁,但当我这样做的时候,我会把它添加到我的OP中。
$ ./RedistMaker Arm
Creating redist for Sensor v5.1.2.1
Cleaning previous outputs...
Building...
make: Entering directory `/home/ubuntu/kinect/SensorKinect/Platform/Linux/Build'
make -C XnCore CFG=Release
make -C XnDeviceSensorV2 CFG=Release
... output omitted here ...
In file included from /usr/include/ni/XnTypes.h:28:0,
from /usr/include/ni/XnModuleInterface.h:27,
from /usr/include/ni/XnModuleCppInterface.h:33,
from ../../../../Source/XnDeviceSensorV2/XnSensorProductionNode.h:28,
from ../../../../Source/XnDeviceSensorV2/XnSensorGenerator.h:28,
from ../../../../Source/XnDeviceSensorV2/XnSensorMapGenerator.h:28,
from ../../../../Source/XnDeviceSensorV2/XnSensorDepthGenerator.h:28,
from ../../../../Source/XnDeviceSensorV2/XnSensorDepthGenerator.cpp:25:
../../../../Source/XnDeviceSensorV2/XnSensorDepthGenerator.cpp: In member function 'virtual XnSensorGenerator* XnExportedSensorDepthGenerator::CreateGenerator(xn::Context&, xn::Device&, XnDeviceBase*, const XnChar*)':
/usr/include/ni/XnOS.h:327:49: error: cannot allocate an object of abstract type 'XnSensorDepthGenerator'
#define XN_NEW(type, ...) new type(__VA_ARGS__)
^
../../../../Source/XnDeviceSensorV2/XnSensorDepthGenerator.cpp:339:9: note: in expansion of macro 'XN_NEW'
return XN_NEW(XnSensorDepthGenerator, context, sensor, pSensor, strStreamName);
^
In file included from ../../../../Source/XnDeviceSensorV2/XnSensorDepthGenerator.cpp:25:0:
../../../../Source/XnDeviceSensorV2/XnSensorDepthGenerator.h:39:7: note: because the following virtual functions are pure within 'XnSensorDepthGenerator':
class XnSensorDepthGenerator :
^
In file included from ../../../../Source/XnDeviceSensorV2/XnSensorProductionNode.h:28:0,
from ../../../../Source/XnDeviceSensorV2/XnSensorGenerator.h:28,
from ../../../../Source/XnDeviceSensorV2/XnSensorMapGenerator.h:28,
from ../../../../Source/XnDeviceSensorV2/XnSensorDepthGenerator.h:28,
from ../../../../Source/XnDeviceSensorV2/XnSensorDepthGenerator.cpp:25:
/usr/include/ni/XnModuleCppInterface.h:220:20: note: virtual XnStatus xn::ModuleAlternativeViewPointInterface::GetPixelCoordinatesInViewPoint(xn::ProductionNode&, XnUInt32, XnUInt32, XnUInt32&, XnUInt32&)
virtual XnStatus GetPixelCoordinatesInViewPoint(ProductionNode& other, XnUInt32 x, XnUInt32 y, XnUInt32& altX, XnUInt32& altY) = 0;
^
make[1]: *** [Arm-Release/XnSensorDepthGenerator.o] Error 1
... more output omitted here ...
/****************************************************************************
* *
* PrimeSense Sensor 5.x Alpha *
* Copyright (C) 2011 PrimeSense Ltd. *
* *
* This file is part of PrimeSense Sensor. *
* *
* PrimeSense Sensor is free software: you can redistribute it and/or modify*
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* PrimeSense Sensor is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with PrimeSense Sensor. If not, see <http://www.gnu.org/licenses/>.*
* *
****************************************************************************/
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include "XnSensorDepthGenerator.h"
#include <XnOpenNI.h>
#include <XnOS.h>
#include <XnPsVersion.h>
#include <XnCommon.h>
#include <math.h>
//---------------------------------------------------------------------------
// XnSensorDepthGenerator class
//---------------------------------------------------------------------------
XnSensorDepthGenerator::XnSensorDepthGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName) :
XnSensorMapGenerator(context, sensor, pSensor, strStreamName),
m_hRWPropCallback(NULL)
{
}
XnSensorDepthGenerator::~XnSensorDepthGenerator()
{
if (m_hRWPropCallback != NULL)
{
UnregisterFromProps(m_hRWPropCallback);
}
}
XnStatus XnSensorDepthGenerator::Init()
{
XnStatus nRetVal = XN_STATUS_OK;
nRetVal = XnSensorMapGenerator::Init();
XN_IS_STATUS_OK(nRetVal);
const XnChar* aProps[] =
{
XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE,
XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE,
NULL
};
m_hRWPropCallback;
nRetVal = RegisterToProps(RealWorldTranslationPropChanged, this, m_hRWPropCallback, aProps);
XN_IS_STATUS_OK(nRetVal);
nRetVal = UpdateRealWorldTranslationData();
if (nRetVal != XN_STATUS_OK)
{
UnregisterFromProps(m_hRWPropCallback);
m_hRWPropCallback = NULL;
return (nRetVal);
}
return (XN_STATUS_OK);
}
XnBool XnSensorDepthGenerator::IsCapabilitySupported(const XnChar* strCapabilityName)
{
return (strcmp(strCapabilityName, XN_CAPABILITY_USER_POSITION) == 0 ||
strcmp(strCapabilityName, XN_CAPABILITY_ALTERNATIVE_VIEW_POINT) == 0 ||
strcmp(strCapabilityName, XN_CAPABILITY_FRAME_SYNC) == 0 ||
XnSensorMapGenerator::IsCapabilitySupported(strCapabilityName));
}
XnDepthPixel* XnSensorDepthGenerator::GetDepthMap()
{
return (XnDepthPixel*)m_pStreamData->pData;
}
XnDepthPixel XnSensorDepthGenerator::GetDeviceMaxDepth()
{
XnUInt64 nValue;
m_pSensor->GetProperty(m_strModule, XN_STREAM_PROPERTY_DEVICE_MAX_DEPTH, &nValue);
return (XnDepthPixel)nValue;
}
void XnSensorDepthGenerator::GetFieldOfView(XnFieldOfView& FOV)
{
FOV = m_FOV;
}
XnStatus XnSensorDepthGenerator::RegisterToFieldOfViewChange(XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
return m_fovChangedEvent.Register(handler, pCookie, hCallback);
}
void XnSensorDepthGenerator::UnregisterFromFieldOfViewChange(XnCallbackHandle hCallback)
{
m_fovChangedEvent.Unregister(hCallback);
}
XnStatus XnSensorDepthGenerator::UpdateRealWorldTranslationData()
{
XnStatus nRetVal = XN_STATUS_OK;
XnUInt64 nZPD;
nRetVal = GetIntProperty(XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE, nZPD);
XN_IS_STATUS_OK(nRetVal);
XnDouble fZPPS;
nRetVal = GetRealProperty(XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE, fZPPS);
XN_IS_STATUS_OK(nRetVal);
m_FOV.fHFOV = 2*atan(fZPPS*XN_SXGA_X_RES/2/nZPD);
m_FOV.fVFOV = 2*atan(fZPPS*XN_VGA_Y_RES*2/2/nZPD);
nRetVal = m_fovChangedEvent.Raise();
XN_IS_STATUS_OK(nRetVal);
return (XN_STATUS_OK);
}
void XnSensorDepthGenerator::RealWorldTranslationPropChanged(void* pCookie)
{
XnSensorDepthGenerator* pThis = (XnSensorDepthGenerator*)pCookie;
pThis->UpdateRealWorldTranslationData();
}
XnUInt32 XnSensorDepthGenerator::GetSupportedUserPositionsCount()
{
return 4;
}
XnStatus XnSensorDepthGenerator::SetUserPosition(XnUInt32 nIndex, const XnBoundingBox3D& Position)
{
// set (we only support Z boxing for now)
XnDepthAGCBin bin;
bin.nBin = (XnUInt16)nIndex;
bin.nMin = (XnUInt16)Position.LeftBottomNear.Z;
bin.nMax = (XnUInt16)Position.RightTopFar.Z;
return m_pSensor->SetProperty(m_strModule, XN_STREAM_PROPERTY_AGC_BIN, XN_PACK_GENERAL_BUFFER(bin));
}
XnStatus XnSensorDepthGenerator::GetUserPosition(XnUInt32 nIndex, XnBoundingBox3D& Position)
{
XnStatus nRetVal = XN_STATUS_OK;
// get
XnDepthAGCBin bin;
bin.nBin = (XnUInt16)nIndex;
nRetVal = m_pSensor->GetProperty(m_strModule, XN_STREAM_PROPERTY_AGC_BIN, XN_PACK_GENERAL_BUFFER(bin));
XN_IS_STATUS_OK(nRetVal);
XnMapOutputMode MapOutputMode;
nRetVal = GetMapOutputMode(MapOutputMode);
XN_IS_STATUS_OK(nRetVal);
// we only support Z position for now
Position.LeftBottomNear.Z = bin.nMin;
Position.RightTopFar.Z = bin.nMax;
Position.LeftBottomNear.X = 0;
Position.RightTopFar.X = (XnFloat)(MapOutputMode.nXRes - 1);
Position.LeftBottomNear.Y = 0;
Position.RightTopFar.Y = (XnFloat)(MapOutputMode.nYRes - 1);
return (XN_STATUS_OK);
}
XnStatus XnSensorDepthGenerator::RegisterToUserPositionChange(XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
const XnChar* aProps[] =
{
XN_STREAM_PROPERTY_AGC_BIN,
NULL
};
return RegisterToProps(handler, pCookie, hCallback, aProps);
}
void XnSensorDepthGenerator::UnregisterFromUserPositionChange(XnCallbackHandle hCallback)
{
UnregisterFromProps(hCallback);
}
XnBool XnSensorDepthGenerator::IsSensorImageNode(xn::ProductionNode& OtherNode)
{
xn::NodeInfo info = OtherNode.GetInfo();
XnVersion Version;
Version.nMajor = XN_PS_MAJOR_VERSION;
Version.nMinor = XN_PS_MINOR_VERSION;
Version.nMaintenance = XN_PS_MAINTENANCE_VERSION;
Version.nBuild = XN_PS_BUILD_VERSION;
// check if this view point is image from this DLL
if (info.GetDescription().Type != XN_NODE_TYPE_IMAGE ||
strcmp(info.GetDescription().strName, XN_DEVICE_NAME) != 0 ||
strcmp(info.GetDescription().strVendor, XN_VENDOR_PRIMESENSE) != 0 ||
xnVersionCompare(&info.GetDescription().Version, &Version) != 0)
{
return FALSE;
}
// check if it uses the same device
xn::NodeInfoList needed = info.GetNeededNodes();
for (xn::NodeInfoList::Iterator it = needed.Begin(); it != needed.End(); ++it)
{
if ((*it).GetDescription().Type == XN_NODE_TYPE_DEVICE &&
strcmp((*it).GetCreationInfo(), m_device.GetInfo().GetCreationInfo()) == 0)
{
return TRUE;
}
}
return FALSE;
}
XnBool XnSensorDepthGenerator::IsViewPointSupported(xn::ProductionNode& OtherNode)
{
return IsSensorImageNode(OtherNode);
}
XnStatus XnSensorDepthGenerator::SetViewPoint(xn::ProductionNode& OtherNode)
{
if (IsSensorImageNode(OtherNode))
{
return SetIntProperty(XN_STREAM_PROPERTY_REGISTRATION, TRUE);
}
else
{
return XN_STATUS_BAD_PARAM;
}
}
XnStatus XnSensorDepthGenerator::ResetViewPoint()
{
return SetIntProperty(XN_STREAM_PROPERTY_REGISTRATION, FALSE);
}
XnBool XnSensorDepthGenerator::IsViewPointAs(xn::ProductionNode& OtherNode)
{
XnUInt64 nValue = FALSE;
GetIntProperty(XN_STREAM_PROPERTY_REGISTRATION, nValue);
return (nValue == TRUE && IsSensorImageNode(OtherNode));
}
XnStatus XnSensorDepthGenerator::RegisterToViewPointChange(XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
const XnChar* aProps[] =
{
XN_STREAM_PROPERTY_REGISTRATION,
NULL
};
return RegisterToProps(handler, pCookie, hCallback, aProps);
}
void XnSensorDepthGenerator::UnregisterFromViewPointChange(XnCallbackHandle hCallback)
{
UnregisterFromProps(hCallback);
}
XnBool XnSensorDepthGenerator::CanFrameSyncWith(xn::ProductionNode& OtherNode)
{
return (IsSensorImageNode(OtherNode));
}
XnStatus XnSensorDepthGenerator::FrameSyncWith(xn::ProductionNode& OtherNode)
{
if (IsSensorImageNode(OtherNode))
{
return m_pSensor->SetProperty(XN_MODULE_NAME_DEVICE, XN_MODULE_PROPERTY_FRAME_SYNC, (XnUInt64)TRUE);
}
else
{
return XN_STATUS_BAD_PARAM;
}
}
XnStatus XnSensorDepthGenerator::StopFrameSyncWith(xn::ProductionNode& /*OtherNode*/)
{
// we assume the other node is the image one (this is the only one we started)
return m_pSensor->SetProperty(XN_MODULE_NAME_DEVICE, XN_MODULE_PROPERTY_FRAME_SYNC, (XnUInt64)FALSE);
}
XnBool XnSensorDepthGenerator::IsFrameSyncedWith(xn::ProductionNode& OtherNode)
{
XnUInt64 nValue = FALSE;
m_pSensor->GetProperty(XN_MODULE_NAME_DEVICE, XN_MODULE_PROPERTY_FRAME_SYNC, &nValue);
return (nValue == TRUE && IsSensorImageNode(OtherNode));
}
XnStatus XnSensorDepthGenerator::RegisterToFrameSyncChange(XnModuleStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
{
const XnChar* aProps[] =
{
XN_MODULE_PROPERTY_FRAME_SYNC,
NULL
};
return RegisterToProps(handler, pCookie, hCallback, aProps, XN_MODULE_NAME_DEVICE);
}
void XnSensorDepthGenerator::UnregisterFromFrameSyncChange(XnCallbackHandle hCallback)
{
UnregisterFromProps(hCallback);
}
void XnSensorDepthGenerator::FilterProperties(XnActualPropertiesHash* pHash)
{
XnSensorMapGenerator::FilterProperties(pHash);
pHash->Remove(XN_STREAM_PROPERTY_REGISTRATION);
pHash->Remove(XN_STREAM_PROPERTY_DEVICE_MAX_DEPTH);
}
//---------------------------------------------------------------------------
// XnExportedSensorDepthGenerator class
//---------------------------------------------------------------------------
XnExportedSensorDepthGenerator::XnExportedSensorDepthGenerator() :
XnExportedSensorGenerator(XN_NODE_TYPE_DEPTH, XN_STREAM_TYPE_DEPTH)
{}
XnSensorGenerator* XnExportedSensorDepthGenerator::CreateGenerator(xn::Context& context, xn::Device& sensor, XnDeviceBase* pSensor, const XnChar* strStreamName)
{
return XN_NEW(XnSensorDepthGenerator, context, sensor, pSensor, strStreamName);
}
XnStatus XnSensorDepthGenerator::GetPixelCoordinatesInViewPoint(xn::ProductionNode& other, XnUInt32 x, XnUInt32 y, XnUInt32& altX, XnUInt32& altY)
{
return 0;
}