我正在尝试用c ++编写一个LED条带驱动程序.现在我有一个Strip班级和一个Driver班级; 所述Strip类夺取LED条与几个像素,而Driver类聚合的Strip数据到单个缓冲器送过来一个UDP连接.
相关的部分类:
class Strip {
public:
...
??? getPixelData();
int getPixelDataLength();
protected:
std::vector<unsigned char> mPixelData;
class Driver {
public:
...
void aggregateStrips();
protected:
vector<unsigned char> mBuffer;
Run Code Online (Sandbox Code Playgroud)
serialize将所有红绿蓝像素数据写入a vector<unsigned char>.然后驱动程序调用Strip.getPixelData()以获取地址mPixelData,并计算getPixelDataLength()出多少字节memcpy().
aggregateStrips() 做这样的事情:
int packetLength = 0;
for(auto strip : Strips) {
memcpy(&mBuffer[packetLength], strip->getPixelData(), strip->getPixelDataLength());
packetLength += strip.getPixelDataLength();
}
Run Code Online (Sandbox Code Playgroud)
我的问题是 - 应该getPixelData()返回什么?它应该shared_ptr向向量返回智能指针(?)吗?或者也许是参考?我只想要地址(和长度),因为我打算这样memcpy做.
谢谢!
我试图使用numpy.meshgrid和pylab.imshow()创建等高线图; 这首先使用了我在stackoverflow上找到的一些技巧,真的很好用(谢谢你!:D)
f = scipy.linspace(1e5,1e6,100)
A = scipy.linspace(1e3,1e5,100)
ff,AA = numpy.meshgrid(f,A)
SLP = calc_SLP2D(ff,AA)
maxAmps = maxA(f)
print maxAmps
brezovich = calc_SLP2D(f,maxAmps)
print brezovich
pylab.imshow(SLP,origin='lower')
pylab.plot(f,maxA(f))
pylab.colorbar()
pylab.xlabel('Frequency [kHz]',{'fontsize':20})
pylab.ylabel('Field Amplitude [A/m]',{'fontsize':20})
pylab.title('Brezovich Criterion',{'fontsize':20})
pylab.grid()
pylab.show()
Run Code Online (Sandbox Code Playgroud)
轴不正确的轮廓图像http://web.mit.edu/scottnla/Public/SLP_contour.pdf
但是,您会注意到轴的编号是两个输入矩阵的大小而不是实际值.纵坐标应从100,000到1,000,000,纵坐标从1000到5000.我在stackoverflow上读到,解决方案是使用'extent'选项,如下所示:
pylab.imshow(SLP,origin='lower',extent=(ff.min(),ff.max(),AA.min(),AA.max()))
Run Code Online (Sandbox Code Playgroud)
这确实修复了轴,但缩放图像是一种非常奇怪的方式:
具有正确轴但不正确图形的等高线图http://web.mit.edu/scottnla/Public/SLP_contour2.pdf
而且我不确定是什么原因引起的.
关于如何重新缩放轴而不使图像变得如此奇怪的任何想法?
谢谢!!
nathan lachenmyer
在尝试比较python中的日期时,我注意到了一些非常奇怪的行为.我正在尝试使用日期来检查是否要将项目添加到MySQL数据库(使用mysqldb库),并且在比较日期时,我会遇到奇怪的行为:
代码是:
latestDate = pullDateFromTable() #pull the latest item from the table
for transaction in transactions:
print "Transaction Time:",transaction.date
print "Latest Entry:",latestDate
if transaction.date > latestDate:
print "Transaction is new, added product"
#insert item to MySQL database
else:
print "Old transaction, did not add product"
Run Code Online (Sandbox Code Playgroud)
输出是:
Transaction Time: Thu Oct 4 11:42:25 2012
Latest Entry: Thu Oct 4 11:42:25 2012
Old transaction, did not add product
Transaction Time: Wed Oct 3 22:11:48 2012
Latest Entry: Thu Oct 4 11:42:25 2012 …Run Code Online (Sandbox Code Playgroud) 我正在使用 openframeworks 创建一个项目(完整源代码在这里: https: //github.com/morphogencc/ofxAsio/tree/master/example-udpreceiver),并且空项目似乎编译得很好。
我添加了 ASIO 库和一些标头类,现在该项目似乎出现以下错误:
1>------ Build started: Project: example-udpreceiver, Configuration: Debug x64 ------
1> main.cpp
1>cl : Command line error D8049: cannot execute 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\c1xx.dll': command line is too long to fit in debug record
1>cl : Command line error D8040: error creating or communicating with child process
我在 stackoverflow 甚至 Microsoft 的页面上都找不到任何错误 D8049 的示例,而且 google 也没有找到任何结果。唯一有用的一个是这个 github 问题:
https://github.com/deplinenoise/tundra/issues/270
但我仍然不确定是什么原因导致了这个问题。有谁熟悉此错误,并且可以推荐一种方法来解决导致该错误的原因吗?
提前致谢!
c++ compiler-errors openframeworks visual-studio visual-studio-2015
我正在做一个包含 ASIO 的项目。我添加了库和头文件,但是当我有一个包含 的文件时asio.hpp,我收到以下错误:
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/config.hpp(229): warning C4005: 'ASIO_ERROR_CATEGORY_NOEXCEPT': macro redefinition (compiling source file src\ofApp.cpp)
1> c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/config.hpp(215): note: see previous definition of 'ASIO_ERROR_CATEGORY_NOEXCEPT' (compiling source file src\ofApp.cpp)
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/impl/win_thread.ipp(59): error C2039: 'CreateEvent': is not a member of '`global namespace'' (compiling source file src\ofApp.cpp)
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/impl/win_thread.ipp(59): error C3861: 'CreateEvent': identifier not found (compiling source file src\ofApp.cpp)
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/impl/win_thread.ipp(69): error C2039: 'CreateEvent': is not a member of '`global namespace'' (compiling source file src\ofApp.cpp)
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/impl/win_thread.ipp(69): error C3861: 'CreateEvent': identifier not found (compiling source file src\ofApp.cpp) …Run Code Online (Sandbox Code Playgroud) 我正在尝试编译一个小 C++ 程序,该程序使用 libv4l2 从相机捕获图像,然后使用 asio 通过 UDP 将其发送到单独的计算机。
项目的文件结构为:
project/
dependencies/
asio/
cpp/
cpp_server/
cpp_client/
Makefile
src/
cpp_client.cpp
ImageClient.cpp
ImageClient.h
ImageProtocol.h
Run Code Online (Sandbox Code Playgroud)
我的项目 Makefile 是:
CC=g++
CPP_FILES := $(wildcard src/*.cpp)
OBJ_FILES := $(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o)))
LD_FLAGS := -L../../dependencies/asio/asio
INCLUDES := -I../../dependencies/asio/asio/include
CC_FLAGS := -Wall $(INCLUDES) -fpermissive -std=c++14 -DASIO_STANDALONE
client.exe : $(OBJ_FILES)
$(CC) $(LD_FLAGS) -o $@ $^
obj/%.o: src/%.cpp
$(CC) $(CC_FLAGS) -c -o $@ $<
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试编译它时,我的编译器会吐出数十个undefined referenceASIO 函数的错误:
cpp_client.cpp:(.text+0x15dc): undefined reference to `asio::error::get_netdb_category()'
cpp_client.cpp:(.text+0x15ec): undefined reference to `asio::error::get_addrinfo_category()'
cpp_client.cpp:(.text+0x15fc): …Run Code Online (Sandbox Code Playgroud) c++ ×4
boost-asio ×2
python ×2
c ×1
linux ×1
makefile ×1
matplotlib ×1
namespaces ×1
numpy ×1
reference ×1
scipy ×1
vector ×1