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

Sample code not giving any output neither any error #46

Open
lafith opened this issue Jan 21, 2022 · 4 comments
Open

Sample code not giving any output neither any error #46

lafith opened this issue Jan 21, 2022 · 4 comments

Comments

@lafith
Copy link

lafith commented Jan 21, 2022

Hi,
I built libuvc in windows without any error following your instructions. I wrote few lines just to check if it is working. It is running without any error but it is also not printing out anything.

Screenshot (33)

main.cpp

#include <iostream>
#include <libuvc/libuvc.h>

int main(){
  std::cout<<"UVC Test:"<<std::endl;
  uvc_context_t *ctx = nullptr;
  uvc_error_t res = uvc_init(&ctx, nullptr);
  if (res < 0)
    {
        uvc_perror(res, "uvc_init error");
        std::cout<<"error"<<std::endl;
    }
    uvc_exit(ctx);
    std::cout<<"Done!"<<std::endl;
  return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.0.0)
project(WebCam_MicrosoftMediaFoundation VERSION 0.1.0)

include_directories(include)
file(GLOB SOURCES "src/*.cpp")

find_package(OpenCV REQUIRED)
include_directories( ${OpenCV_INCLUDE_DIRS} )

set(libuvc_DIR C:/libuvc/build/CMakeFiles)
find_package(libuvc REQUIRED)
include_directories( C:/libuvc/include )

include(CTest)
enable_testing()

add_executable(OpenCV_Test
                ${SOURCES})

target_link_libraries( OpenCV_Test ${OpenCV_LIBS} C:/libuvc/build/Release/uvc.lib)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
@papr
Copy link

papr commented Jan 21, 2022

Hi,
Unfortunately, I do not have an idea what could be going wrong in your example. I would recommend starting with the simplest possible example (just printing something) and then adding complexity step by step to find the step causing the program to stop working.

@lafith
Copy link
Author

lafith commented Jan 21, 2022

Ok I tried this approach and this is when I am getting no output nor error. Do you have any idea where could be the problem?

#include <iostream>
#include <libuvc/libuvc.h>

int main(){
  std::cout<<"UVC Test:"<<std::endl;
  uvc_context_t *ctx = nullptr;
  uvc_error_t res = uvc_init(&ctx, nullptr);
//  if (res < 0)
//    {
//        uvc_perror(res, "uvc_init error");
//        std::cout<<"error"<<std::endl;
//    }
//    uvc_exit(ctx);
//   std::cout<<"Done!"<<std::endl;
     return 0;
}

@papr
Copy link

papr commented Jan 21, 2022

@lafith uvc_init compares against NULL, not nullptr. I do not know enough about c++ to know if this makes a difference. Please give passing NULL instead a try.

@lafith
Copy link
Author

lafith commented Jan 21, 2022

@papr
No, same result :(

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

No branches or pull requests

2 participants