* @brief This is the internal tracking function that makes use of LivMV to do 1 track step * @param trackingIndex This is the index of the Marker we should track in the args * @param args Multiple arguments global to the whole track, not just this step * @param trackTime The search frame time, that is, the frame to track */
| 1018 | * @param trackTime The search frame time, that is, the frame to track |
| 1019 | */ |
| 1020 | bool |
| 1021 | TrackerContextPrivate::trackStepLibMV(int trackIndex, |
| 1022 | const TrackArgs& args, |
| 1023 | int trackTime) |
| 1024 | { |
| 1025 | assert( trackIndex >= 0 && trackIndex < args.getNumTracks() ); |
| 1026 | |
| 1027 | #if defined(CERES_USE_OPENMP) && defined(_OPENMP) |
| 1028 | // Set the number of threads Ceres may use |
| 1029 | QThreadPool* tp = QThreadPool::globalInstance(); |
| 1030 | omp_set_num_threads(tp->maxThreadCount() - tp->activeThreadCount() - 1); |
| 1031 | #endif |
| 1032 | |
| 1033 | const std::vector<TrackMarkerAndOptionsPtr>& tracks = args.getTracks(); |
| 1034 | const TrackMarkerAndOptionsPtr& track = tracks[trackIndex]; |
| 1035 | mv::AutoTrackPtr autoTrack = args.getLibMVAutoTrack(); |
| 1036 | QMutex* autoTrackMutex = args.getAutoTrackMutex(); |
| 1037 | bool enabledChans[3]; |
| 1038 | args.getEnabledChannels(&enabledChans[0], &enabledChans[1], &enabledChans[2]); |
| 1039 | |
| 1040 | |
| 1041 | { |
| 1042 | // Add a marker to the auto-track at the tracked time: the mv::Marker struct is filled with the values of the Natron TrackMarker at the trackTime |
| 1043 | QMutexLocker k(autoTrackMutex); |
| 1044 | if ( trackTime == args.getStart() ) { |
| 1045 | bool foundStartMarker = autoTrack->GetMarker(0, trackTime, trackIndex, &track->mvMarker); |
| 1046 | assert(foundStartMarker); |
| 1047 | Q_UNUSED(foundStartMarker); |
| 1048 | track->mvMarker.source = mv::Marker::MANUAL; |
| 1049 | } else { |
| 1050 | natronTrackerToLibMVTracker(false, enabledChans, *track->natronMarker, trackIndex, trackTime, args.getStep(), args.getFormatHeight(), &track->mvMarker); |
| 1051 | autoTrack->AddMarker(track->mvMarker); |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | if (track->mvMarker.source == mv::Marker::MANUAL) { |
| 1056 | // This is a user keyframe or the first frame, we do not track it |
| 1057 | assert( trackTime == args.getStart() || track->natronMarker->isUserKeyframe(track->mvMarker.frame) ); |
| 1058 | #ifdef TRACE_LIB_MV |
| 1059 | qDebug() << QThread::currentThread() << "TrackStep:" << trackTime << "is a keyframe"; |
| 1060 | #endif |
| 1061 | setKnobKeyframesFromMarker(track->mvMarker, args.getFormatHeight(), 0, track->natronMarker); |
| 1062 | } else { |
| 1063 | // Make sure the reference frame is in the auto-track: the mv::Marker struct is filled with the values of the Natron TrackMarker at the reference_frame |
| 1064 | { |
| 1065 | QMutexLocker k(autoTrackMutex); |
| 1066 | mv::Marker m; |
| 1067 | if ( !autoTrack->GetMarker(0, track->mvMarker.reference_frame, trackIndex, &m) ) { |
| 1068 | natronTrackerToLibMVTracker(true, enabledChans, *track->natronMarker, track->mvMarker.track, track->mvMarker.reference_frame, args.getStep(), args.getFormatHeight(), &m); |
| 1069 | autoTrack->AddMarker(m); |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | |
| 1074 | assert(track->mvMarker.reference_frame != track->mvMarker.frame); |
| 1075 | |
| 1076 | |
| 1077 | #ifdef TRACE_LIB_MV |
nothing calls this directly
no test coverage detected