Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

how to use a non uobject array in a uobject class without getting memory problems.

I am using an external library (opencv with contrib) and obviously it doesn't take in UObjects. My cpp contains the following in the tick function:

            std::vector < int > ids;
             std::vector < int > idsR;
             std::vector < std::vector < Point2f > > corners, rejected;
             std::vector<Vec3d> rvecs, tvecs;
             aruco::detectMarkers(image, dictionary, corners, ids, detectorParameters);
             if (corners.size() > 1)
                 aruco::estimatePoseSingleMarkers(corners, markerSize, cameraMatrix, distCoeffs, rvecs, tvecs);
                 for (int i = 0; i < ids.size(); i++)
                     UPWMatrix44 *tempMatrix = NewObject<UPWMatrix44>();
                     tempMatrix = FormMatrixFromVec3d(rvecs[i], tvecs[i]);

and the h file

 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = PWAR)
         TArray<UPWMatrix44*> AllVisibleMarkers;
 Mat cameraMatrix, distCoeffs;

Where detectMarkers writes to corners and ids, estimatePoseSingleMarkers writes to rvecs and tvecs and UPWMatrix being a Uobject class. This implementation, with std::vector s instead of TArrays for the tempMatrix and AllVisibleMarkers worked without a problem. Now as soon as I show a marker in front of the camera (where previously detectMarkers was returning corners and ids correctly) I get an "Access violation writing location" at the line of detectMarkers.

I suspect that it is to do with the UE4 garbage collection but I can't find anything online about how to stop them being destroyed without making the vectors into a different format that the opencv library can't handle. There may also be problems with the tempMatrix and AllVisibleMarkers but I have yet to hit a breakpoint inside the if statement so I have no idea yet. If I force in a single value for corners and ids it will still not get into the if statement but instead breaks at line 85 of MallocTBB.cpp NewPtr = scalable_realloc(Ptr, NewSize) which makes me even more confident it's a problem with memory allocation that I don't understand.

image, dictionary, detectorParamaters, cameraMatrix and distCoeffs are all set prior to this and as best I can tell are set correctly (I can't get the pdb files to step through them but the data that is visible all looks correct)

All help is gratefully appreciated, this is pretty much the last stumbling block on my project and it's driving me insane.

Philip Wilson.

Product Version: UE 4.13
more ▼

asked Mar 08 '17 at 06:49 PM in C++ Programming

avatar image

6 1 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question