我正在开发一个应该在Python中使用的DLL.我有一个回调函数来发送我的参数(在一个单独的标题中定义):
typedef int(*call_nBest)(char **OutList, float* confList, int nB);
所以,我以这种方式使用这个回调:
#define TEXT_BUFFER_MAX_SIZE 50
call_nBest nBestList;
void Xfunction(const char* aLineThatWillBeConvertedInAList){
char **results;
float *confidences;
confidences=new float[nBest];
results=new char*[nBest];
for(int i=0; i<nBest; i++) results[i]=new char[TEXT_BUFFER_MAX_SIZE];
MakeLine2List(aLineThatWillBeConvertedInAList,results,confidences);
/*At this function I am having the error :(*/
nBestList(results,confidences,nBest); // Passing the values to my callback
for(int i=0; i<nBest; i++) delete [] results[i];
delete [] confidences;
delete [] results;
}
Run Code Online (Sandbox Code Playgroud)
我以这种方式导出它:
__declspec(dllexport) int ResultCallback(call_nBest theList){
nBestList = theList;
return(0);
}
Run Code Online (Sandbox Code Playgroud)
我以这种方式首先在另一个C++应用程序中测试了我的回调:
int MyCallback(char **OutLi, float* confLi, …Run Code Online (Sandbox Code Playgroud) 我通过调用C++ DLL设计一个Python应用程序,我已经发布我的DLL和Python 3.4之间的相互作用我这里.但是现在我需要在流程中执行一些涉及基于线程的模型的过程,并且我的回调函数看起来将所有prints 放入队列中,并且仅当我的流式传输结束时,才会打印所有信息.
def callbackU(OutList, ConList, nB):
for i in range(nB):
out_list_item = cast(OutList[i], c_char_p).value
print("{}\t{}".format(ConList[i], out_list_item))
return 0
Run Code Online (Sandbox Code Playgroud)
我试图使用下一种方法,但所有这些方法看起来都以相同的方式工作:
from threading import Lock
print_lock = Lock()
def save_print(*args, **kwargs):
with print_lock:
print (*args, **kwargs)
def callbackU(OutList, ConList, nB):
for i in range(nB):
out_list_item = cast(OutList[i], c_char_p).value
save_print(out_list_item))
return 0
Run Code Online (Sandbox Code Playgroud)
和:
import sys
def callbackU(OutList, ConList, nB):
for i in range(nB):
a = cast(OutList[i], c_char_p).value
sys.stdout.write(a)
sys.stdout.flush()
return 0
Run Code Online (Sandbox Code Playgroud)
我希望我的回调在调用它时打印它的消息,而不是在整个过程结束时.
我试图从图像的非规则区域中提取 N 个样本,由轮廓分隔,我确实有轮廓像素的位置。提取的样本必须遵循随机均匀分布。这就是我所拥有的:

这就是我的愿望:

知道如何做吗?干杯!
我正在Visual Studio中构建一个应用程序.我需要创建一些要在dll中使用的文件,但我希望在查看文件夹时隐藏这些文件.我怎么能在C++程序中这样做?
通过交互方式,您可以通过右键单击文件来隐藏文件,选择"属性"并选择"隐藏".问题是,如何通过C++程序做同等的事情?