I'm trying to build OpenBR, I followed the steps on http://openbiometrics.org/docs/install/#windows but I get stuck on this. The first time I used nmake, I got to 19%. Last week it worked on another computer
(thesame compiler, cmd, ...). It broke down now I have to rebuild it. I've been looking for over 15 hours now.
C:\openbr\build-msvc2013>nmake
Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.
[ 2%] Built target models
[ 3%] Automatic moc for target openbr
[ 3%] Built target openbr_automoc
[ 4%] Building CXX object openbr/CMakeFiles/openbr.dir/plugins/classification/cascade_classifier.cpp.obj
cascade_classifier.cpp
C:\openbr\openbr\plugins\classification\cascade_classifier.cpp(229) : error C2660: 'br::Classifier::train' : function does not take 1 arguments
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~2.0\VC\bin\X86_AM~1\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
This is the part where it goes wrong:
void train(const TemplateList &data)
{
foreach (const Template &t, data)
t.file.get<float>("Label") == 1.0f ? posImages.append(t) : negImages.append(t);
qDebug() << "Total images:" << data.size()
<< "\nTotal positive images:" << posImages.size()
<< "\nTotal negative images:" << negImages.size();
posIndices = Common::RandSample(posImages.size(), posImages.size(), true);
negIndices = Common::RandSample(negImages.size(), negImages.size(), true);
stages.reserve(numStages);
for (int i = 0; i < numStages; i++) {
qDebug() << "===== TRAINING" << i << "stage =====";
qDebug() << "<BEGIN";
Classifier *next_stage = Classifier::make(stageDescription, NULL);
stages.append(next_stage);
float currFAR = getSamples();
if (currFAR < maxFAR && !requireAllStages) {
qDebug() << "FAR is below required level! Terminating early";
return;
}
stages.last()->train(posSamples + negSamples);
qDebug() << "END>";
}
}
This is the whole file:
https://github.com/biometrics/openbr/blob/master/openbr/plugins/classification/cascade_classifier.cpp
Related
I have a C++ program that can take a sequence of images and create a video and write them to file. This works well on my Mac and Ubuntu computer. I have also compiled my C++ program for ios. When I try and do the same thing on iOS it does not work unfortunately.
I get the following error:
VideoProcessing.cpp:66 INFO| Width: 1920 frame_height: 1080
INFO| Output video path: /private/var/containers/Bundle/Application/0886D03C-55DB-48FA-9085-0AE1A6000B2A/TestVideoProcess.app/output_video0.mov
2022-09-25 13:51:53.535999+0200 TestVideoProcess[72327:4995351] The operation could not be completed
2022-09-25 13:51:53.536 ( 0.681s) [ 4C3917] VideoProcessing.cpp:70 INFO| VideoWriter created
2022-09-25 13:51:53.542 ( 0.688s) [ 4C3917] VideoProcessing.cpp:77 INFO| Writing frame
2022-09-25 13:51:53.542682+0200 TestVideoProcess[72327:4995351] [mMovieWriterInput isReadyForMoreMediaData] Not ready for media data or ...
2022-09-25 13:51:53.542785+0200 TestVideoProcess[72327:4995351] mMovieWriter.status: 3. Error: The operation could not be completed
The code looks like this:
void writeSubVideos(int anchorFrame, const std::string& video_path,const std::string& out_path) {
cv::VideoCapture video_capture;
video_capture.open(video_path);
if (!video_capture.isOpened())
{
LOG_S(ERROR) << "Error opening video file " << video_path;
return;
}
const auto frame_width = video_capture.get(cv::CAP_PROP_FRAME_WIDTH);
const auto frame_height = video_capture.get(cv::CAP_PROP_FRAME_HEIGHT);
LOG_S(INFO) << "Width: " << frame_width << " frame_height: " << frame_height;
LOG_S(INFO) << "Output video path: " << out_path;
auto video_writer = cv::VideoWriter(out_path, cv::CAP_AVFOUNDATION, cv::VideoWriter::fourcc('M', 'J', 'P', 'G'), kFrameRate, cv::Size(frame_width, frame_height));
int frame_nbr = 0;
LOG_S(INFO) << "VideoWriter created";
while (1)
{
cv::Mat frame;
video_capture >> frame;
frame_nbr++;
if (frame_nbr >= anchorFrame - kFixedWindow && frame_nbr < anchorFrame + kFrameRate) {
LOG_S(INFO) << "Writing frame";
video_writer.write(frame);
}
if (frame_nbr >= anchorFrame + kFrameRate) {
break;
}
}
}
I have been able to write an image to file and load it again. Is there some sort of permission missing?
Why the interpreter complains that library named "math" does not exist?
As far as I know, this library is loaded when invoking luaL_newstate on Lua-5.3.5.
#include "lua.hpp"
#include <iostream>
#include <assert.h>
#include <fstream>
int main()
{
struct lua_State *L = luaL_newstate();
int ret;
std::string fileName("co.lua");
if(fileName.empty())
{
std::cout << "the filename is empty" << std::endl;
return -1;
}
std::ifstream fileScript(fileName, fileScript.in|std::ios::ate);
if(!fileScript.is_open())
{
std::cout << "open file failed" << std::endl;
return -2;
}
size_t size = fileScript.tellg();
if(size <= 0)
{
std::cout << "file has no valid content" << std::endl;
return -3;
}
std::string textCont(size, '\0');
fileScript.seekg(0);
fileScript.read(&textCont[0], size);
if((ret=luaL_loadbuffer(L, textCont.data(), textCont.length(), "co.lua")) == LUA_OK)
{
if((ret=lua_pcall(L, 0, LUA_MULTRET, 0)) != LUA_OK)
{
std::cout << "error in invoking lua_pcall():" << ret << std::endl;
if(lua_isstring(L, -1))
{
const char *errMsg = lua_tostring(L, -1);
lua_pop(L, 1);
std::cout << "script run encounter err:" << errMsg << std::endl;
}
}
}
}
Here is the code snippet(it's very simple) for the file named "co.lua":
a = 1;
b=2;
a=a+1;
math.sin(a)
Here is the error message in the console:
error in invoking lua_pcall():2
script run encounter err:[string "co.lua"]:29: attempt to index a nil value (global 'math')
The documentation states that you need to call luaL_openlibs or luaL_requiref which does not seem to be the case with your posted program.
To have access to these libraries, the C host program should call the luaL_openlibs function, which opens all standard libraries.
Alternatively (emphasis mine):
Alternatively, the host program can open them individually by using luaL_requiref to call:
luaopen_base (for the basic library)
luaopen_package (for the package library)
luaopen_coroutine (for the coroutine library)
luaopen_string (for the string library)
luaopen_utf8 (for the UTF8 library)
luaopen_table (for the table library)
luaopen_math (for the mathematical library)
luaopen_io (for the I/O library)
luaopen_os (for the operating system library)
luaopen_debug (for the debug library).
These functions are declared in lualib.h.
So change your program's first few lines to something like below.
You also need to compare the return value from luaL_newstate with NULL and handle that error condition.
int main()
{
struct lua_State *L = luaL_newstate();
if( L == NULL ) {
puts( "Lua failed to initialize." );
exit(1);
}
luaL_openlibs( L );
// etc
Hi i'm experimenting with dart ffi and i'm having an issue with the following dump
===== CRASH =====
si_signo=Segmentation fault(11), si_code=1, si_addr=(nil)
version=2.12.0-157.0.dev (dev) (Wed Dec 16 01:04:40 2020 -0800) on "linux_x64"
pid=262571, thread=262578, isolate_group=main(0x373e8c0), isolate=main(0x373f140)
isolate_instructions=17fde20, vm_instructions=17fde20
pc 0x00007f1633a00543 fp 0x00007f1656c1d540 wasm_instance_exports+0x13
pc 0x00007f163ce30505 fp 0x00007f1656c1d578 Unknown symbol
pc 0x00007f163ce3023f fp 0x00007f1656c1d5e0 Unknown symbol
pc 0x00007f163ce25553 fp 0x00007f1656c1d6b8 Unknown symbol
pc 0x00007f163ce2453c fp 0x00007f1656c1d700 Unknown symbol
pc 0x00007f163ce24233 fp 0x00007f1656c1d728 Unknown symbol
pc 0x00007f163ce2419f fp 0x00007f1656c1d750 Unknown symbol
pc 0x00007f163ce240cf fp 0x00007f1656c1d7a8 Unknown symbol
pc 0x00007f163ce2300e fp 0x00007f1656c1d7d8 Unknown symbol
pc 0x00007f163ce22d72 fp 0x00007f1656c1d838 Unknown symbol
pc 0x00007f163ce2276e fp 0x00007f1656c1d870 Unknown symbol
pc 0x00007f1656d8265f fp 0x00007f1656c1d8e8 Unknown symbol
-- End of DumpStackTrace
[exit : sp(0) fp(0x7f1656c1d540) pc(0)]
[dart : sp(0x7f1656c1d550) fp(0x7f1656c1d578) pc(0x7f163ce30505) *dart:ffi_::_FfiTrampoline ]
[dart : sp(0x7f1656c1d588) fp(0x7f1656c1d5e0) pc(0x7f163ce3023f) file:///home/kingwill101/code/wasm-dart/generated_bindings.dart_Wasmer_wasm_instance_exports ]
[dart : sp(0x7f1656c1d5f0) fp(0x7f1656c1d6b8) pc(0x7f163ce25553) file:///home/kingwill101/code/wasm-dart/bin/main.dart_::_helloWorld__async_op ]
[dart : sp(0x7f1656c1d6c8) fp(0x7f1656c1d700) pc(0x7f163ce2453c) file:///home/kingwill101/code/wasm-dart/bin/main.dart_::_helloWorld ]
[dart : sp(0x7f1656c1d710) fp(0x7f1656c1d728) pc(0x7f163ce24233) file:///home/kingwill101/code/wasm-dart/bin/main.dart_::_main ]
[dart : sp(0x7f1656c1d738) fp(0x7f1656c1d750) pc(0x7f163ce2419f) file:///home/kingwill101/code/wasm-dart/bin/main.dart_::_main_main ]
[dart : sp(0x7f1656c1d760) fp(0x7f1656c1d7a8) pc(0x7f163ce240cf) dart:core__Closure#0150898_dyn_call ]
[dart : sp(0x7f1656c1d7b8) fp(0x7f1656c1d7d8) pc(0x7f163ce2300e) dart:isolate_::__delayEntrypointInvocation#1026248_<anonymous closure> ]
[dart : sp(0x7f1656c1d7e8) fp(0x7f1656c1d838) pc(0x7f163ce22d72) dart:core__Closure#0150898_dyn_call ]
[dart : sp(0x7f1656c1d848) fp(0x7f1656c1d870) pc(0x7f163ce2276e) dart:isolate__RawReceivePortImpl#1026248__handleMessage#1026248 ]
[entry : sp(0x7f1656c1d880) fp(0x7f1656c1d8e8) pc(0x7f1656d8265f)]
Aborted (core dumped)
I'm not sure how to get a better output of what exactly is causing the errors as it feels a bit cryptic.
Code crashes here
Pointer<wasm_extern_vec_t> exports = allocate<wasm_extern_vec_t>();
w.wasm_extern_vec_new_empty(exports);
w.wasm_instance_exports(instance, exports);
ffi glue code
typedef _c_wasm_instance_exports = ffi.Void Function(
ffi.Pointer<wasm_instance_t> arg0,
ffi.Pointer<wasm_extern_vec_t> out,
);
typedef _dart_wasm_instance_exports = void Function(
ffi.Pointer<wasm_instance_t> arg0,
ffi.Pointer<wasm_extern_vec_t> out,
);
void wasm_instance_exports(
ffi.Pointer<wasm_instance_t> arg0,
ffi.Pointer<wasm_extern_vec_t> out,
) {
_wasm_instance_exports ??= _dylib.lookupFunction<_c_wasm_instance_exports,
_dart_wasm_instance_exports>('wasm_instance_exports');
return _wasm_instance_exports(
arg0,
out,
);
}
So yeah, are there any resources i can refer to about investigating these crashes?
##edit##
The api is a C exported api from the rust wasmer project
exported header is
#ifndef WASM_API_EXTERN
#ifdef _WIN32
#define WASM_API_EXTERN __declspec(dllimport)
#else
#define WASM_API_EXTERN
#endif
#endif
WASM_API_EXTERN void wasm_instance_exports(const wasm_instance_t*, own wasm_extern_vec_t* out);
rust implementation is at
https://github.com/wasmerio/wasmer/blob/0a4a2c7d24d718e48eb9aa895292d3cbf950f7ed/lib/c-api/src/wasm_c_api/instance.rs#L178
more detailed code
Pointer<wasm_byte_vec_t> wat = allocate<wasm_byte_vec_t>() ;
Pointer<wasm_byte_vec_t> wasm_bytes = allocate<wasm_byte_vec_t>();
w.wasm_byte_vec_new(wat, code.length, Utf8.toUtf8(code).cast());
w.wat2wasm(wat, wasm_bytes);
var engine = w.wasm_engine_new();
var store = w.wasm_store_new(engine);
var module = w.wasm_module_new(store, wasm_bytes);
if (module == nullptr) {
print("> Error compiling module!\n");
return;
}
w.wasm_byte_vec_delete(wasm_bytes);
Pointer<wasm_extern_vec_t> imports = allocate<wasm_extern_vec_t>();
w.wasm_extern_vec_new_empty(imports);
var instance = w.wasm_instance_new(store, module, imports, nullptr);
if (instance != nullptr) {
print("> Error instantiating module %d!\n");
return ;
}
//
Pointer<wasm_extern_vec_t> exports = allocate<wasm_extern_vec_t>();
w.wasm_extern_vec_new_empty(exports);
w.wasm_instance_exports(instance, exports);
if (exports.ref.size == 0) {
print("> Error accessing exports!\n");
return;
}
My c++ source code:
int main(){
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image = imread(argv[1]); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
}
This is just easy code to test opencv.
The CMakeLists.txt :
cmake_minimum_required(VERSION 3.8)
set(PROJECT_NAME testCVCL)
project(${PROJECT_NAME})
find_package(OpenCV 4 REQUIRED)
include_directories(${OpenCV_INCLUDE_DIR})
add_executable(${PROJECT_NAME}
test.cc)
target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBRARIES})
Compilation is fine, but linking has error:
/usr/bin/ld: /usr/lib/libopencv_viz.so.4.1.1: undefined reference to `typeinfo for vtkWriter'
/usr/bin/ld: /usr/lib/libopencv_viz.so.4.1.1: undefined reference to `vtkPolyData::SetStrips(vtkCellArray*)'
/usr/bin/ld: /usr/lib/libopencv_hdf.so.4.1.1: undefined reference to `H5P_CLS_DATASET_CREATE_ID_g'
....
....
and so on
Above error almost generated by libopencv_viz and libopencv_hdf.
I am sure those library exist in "/usr/lib".
So I feel confused.
After I installed these packages:
vtk
hdf5
glew
in my computer, now I can build the project fine.
I have not modify above code.
in this code i load and run test.lua file
int main (){
L = luaL_newstate();
luaL_openlibs(L);
luaL_dofile(L, "test.lua");
lua_close(L);
return 0;
}
my test.lua file contents
print ("s1");
r=require 'simple';
print ("s2");
the simple module is installed before
when run ./lua_c ; output is only: s1
but when run lua test.lua; output is
s1
s2
and r in't nil
simple is failing to load or parse or execute. To find problem, use luaL_loadfile instead of luaL_dofile and check the return value. If non zero, there was a load error, which you can pop off the Lua stack and print. If no error, do the lua_pcall(L, 0, LUA_MULTRET, 0)) to run the chuck created by loadfile, and again check return code for error, pop off stack and print. It would be somehting like this:
int main ()
{
L = luaL_newstate();
luaL_openlibs(L);
if (luaL_loadfile(L, "test.lua"))
{
cout << "Error: " << lua_tostring(L, -1) << endl;
}
else if (lua_pcall(L, 0, LUA_MULTRET, 0))
{
cout << "Error: " << lua_tostring(L, -1) << endl;
}
else
{
// call successful
}
lua_close(L);
return 0;
}
Update: now that you know from the error message that simple.so has undefined symbol: lua_gettop, you know that there is a link error. Perhaps simple.so isn't linked to lua51.so, but since it works from lua.exe, which is linked to lua lib, one would it would work from your app, which is surely linked to it too. Another possibility is that lua.exe is statically linked but simple.so is not linked. Verify that simple.so is linked to lua51.so and that the lib it links to can be found such as via LD_LIBRARY_PATH. Verify lua.exe is linked to same .so.