operating with complex struct/class in Julia from C++

Viewed 73

In the recent project, I am trying to write a simple wrapper of C++ library (OpenCV) to be utilized in Julia with the use of CxxWrap. The case of C++ code (where arguments and return types are my own, rather simple, structs) is working.

The problem I have is with more complex data structures (defined in, let's say OpenCV); in our case (I want it to be simple to understand) I want to get information about the frame, so I execute:

    using PyCall
    const cv2 = pyimport("cv2")

    module CppHello
      using CxxWrap
      @wrapmodule(joinpath(@__DIR__,"libhello"))

      function __init__()
        @initcxx
      end
    end
    
    cap = CppHello.openVideo() // (*)

to above I have two questions:

  • do I have to explicitly define returned type by openVideo() -- suppose for this moment that I want to use only my library in C++ to start any of the OpenCV functions;
  • if "No" to the above can I do something like that:
    cap = cv2.VideoCapture(0)       # from library
    cap.isOpened() && frm = cap.frame() 

The point is that I am interested only in a few operations at frame along with passing returned value to other procedures (show frame utilizing C++ on the screen or save in file). Motivation is a problem of low performance of imshow() executed on Julia level with used PyCall (in contrary with goodFeaturesToTrack or calcOpticalFlowPyrLK) and drastic low FPS compared with C++.

Maybe there is another solution I unnoticed. As I have a problem with (*) I thought that maybe I can simply write a struct (of known elements) of pointers to hold the data returned by C++ functions?

As it is my first edition of the question, I will be grateful for any info about correctness and completeness.

0 Answers
Related