39 for (
int i = 0; i < num_pixels; i++) {
40 const float *pixel = rgba + 4 * i;
42 gray[i] = weight_red * pixel[0] + weight_green * pixel[1] + weight_blue * pixel[2];
53 for (
int i = 0; i < num_pixels; i++) {
54 const uchar *pixel = rgba + i * 4;
56 gray[i] = (weight_red * pixel[0] + weight_green * pixel[1] + weight_blue * pixel[2]) / 255.0f;
79 width = searchibuf->
x;
80 height = searchibuf->
y;
82 gray_pixels = MEM_cnew_array<float>(width * height,
"tracking floatBuf");
86 searchibuf->
float_buffer.
data, gray_pixels, width * height, 0.2126f, 0.7152f, 0.0722f);
90 searchibuf->
byte_buffer.
data, gray_pixels, width * height, 0.2126f, 0.7152f, 0.0722f);
133 if (marker_keyed ==
nullptr) {
137 keyed_framenr = marker_keyed->
framenr;
139 *r_marker_keyed = marker_keyed;
153 ImBuf *ibuf =
nullptr;
157 clip, user, clip_flag, track, curfra, backwards, reference_marker);
171 const bool is_backwards,
193 options->image1_mask =
nullptr;
207 float *reference_search_area,
208 int reference_search_area_width,
209 int reference_search_area_height,
211 const bool is_backward,
212 double dst_pixel_x[5],
213 double dst_pixel_y[5])
216 double src_pixel_x[5], src_pixel_y[5];
224 int new_search_area_width, new_search_area_height;
225 int frame_width, frame_height;
229 frame_width = destination_ibuf->
x;
230 frame_height = destination_ibuf->
y;
237 destination_ibuf, track, marker, &new_search_area_width, &new_search_area_height);
245 frame_width, frame_height, reference_marker, src_pixel_x, src_pixel_y);
247 frame_width, frame_height, marker, dst_pixel_x, dst_pixel_y);
249 if (patch_new ==
nullptr || reference_search_area ==
nullptr) {
255 reference_search_area,
256 reference_search_area_width,
257 reference_search_area_height,
259 new_search_area_width,
260 new_search_area_height,
275 int *reference_framenr)
281 while (reference >= first_marker && reference <= last_marker &&
292 if (reference < first_marker || reference > last_marker) {
296 *reference_framenr = reference->
framenr;
306 ImBuf *reference_ibuf, *destination_ibuf;
307 float *search_area, *mask =
nullptr;
308 int frame_width, frame_height;
309 int search_area_height, search_area_width;
311 int reference_framenr;
313 double dst_pixel_x[5], dst_pixel_y[5];
327 clip, &user, clip_flag, track, reference_framenr, backwards, &reference_marker);
328 if (reference_ibuf ==
nullptr) {
333 if (reference_marker == marker) {
339 if (destination_ibuf ==
nullptr) {
346 reference_ibuf, track, reference_marker, &search_area_width, &search_area_height);
369 frame_width, frame_height, marker, dst_pixel_x, dst_pixel_y);
#define MOVIECLIP_CACHE_SKIP
void BKE_movieclip_get_size(struct MovieClip *clip, const struct MovieClipUser *user, int *r_width, int *r_height)
float BKE_movieclip_remap_clip_to_scene_frame(const struct MovieClip *clip, float framenr)
struct ImBuf * BKE_movieclip_get_ibuf_flag(struct MovieClip *clip, const struct MovieClipUser *user, int flag, int cache_flag)
struct MovieTrackingMarker * BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr)
struct ImBuf * BKE_tracking_get_search_imbuf(const struct ImBuf *ibuf, const struct MovieTrackingTrack *track, const struct MovieTrackingMarker *marker, bool anchored, bool disable_channels)
float * BKE_tracking_track_get_mask(int frame_width, int frame_height, const struct MovieTrackingTrack *track, const struct MovieTrackingMarker *marker)
#define DNA_struct_default_get(struct_name)
@ TRACK_ALGORITHM_FLAG_USE_NORMALIZATION
@ TRACK_ALGORITHM_FLAG_USE_BRUTE
@ TRACK_ALGORITHM_FLAG_USE_MASK
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
CCL_NAMESPACE_BEGIN struct Options options
void IMB_freeImBuf(ImBuf *)
@ LIBMV_TRACK_REGION_FORWARD
@ LIBMV_TRACK_REGION_BACKWARD
void MEM_freeN(void *vmemh)
ccl_device_inline float4 mask(const int4 mask, const float4 a)
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
float minimum_correlation
MovieTrackingMarker * markers
int libmv_trackRegion(const libmv_TrackRegionOptions *, const float *, int, int, const float *, int, int, const double *x1, const double *y1, libmv_TrackRegionResult *result, double *x2, double *y2)
void BKE_tracking_refine_marker(MovieClip *clip, MovieTrackingTrack *track, MovieTrackingMarker *marker, bool backwards)
static bool refine_marker_reference_frame_get(MovieTrackingTrack *track, MovieTrackingMarker *marker, bool backwards, int *reference_framenr)
static ImBuf * tracking_context_get_keyframed_ibuf(MovieClip *clip, MovieClipUser *user, int clip_flag, MovieTrackingTrack *track, int curfra, bool backwards, MovieTrackingMarker **r_marker_keyed)
static void float_rgba_to_gray(const float *rgba, float *gray, int num_pixels, float weight_red, float weight_green, float weight_blue)
static void uint8_rgba_to_float_gray(const uchar *rgba, float *gray, int num_pixels, float weight_red, float weight_green, float weight_blue)
static ImBuf * tracking_context_get_reference_ibuf(MovieClip *clip, MovieClipUser *user, int clip_flag, MovieTrackingTrack *track, int curfra, bool backwards, MovieTrackingMarker **reference_marker)
static bool configure_and_run_tracker(ImBuf *destination_ibuf, MovieTrackingTrack *track, MovieTrackingMarker *reference_marker, MovieTrackingMarker *marker, float *reference_search_area, int reference_search_area_width, int reference_search_area_height, float *mask, const bool is_backward, double dst_pixel_x[5], double dst_pixel_y[5])
static float * track_get_search_floatbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker, int *r_width, int *r_height)
void tracking_configure_tracker(const MovieTrackingTrack *track, float *mask, const bool is_backwards, libmv_TrackRegionOptions *options)
static ImBuf * tracking_context_get_frame_ibuf(MovieClip *clip, MovieClipUser *user, int clip_flag, int framenr)
void tracking_get_marker_coords_for_tracking(int frame_width, int frame_height, const MovieTrackingMarker *marker, double search_pixel_x[5], double search_pixel_y[5])
MovieTrackingMarker * tracking_get_keyframed_marker(MovieTrackingTrack *track, int current_frame, bool backwards)
void tracking_set_marker_coords_from_tracking(int frame_width, int frame_height, MovieTrackingMarker *marker, const double search_pixel_x[5], const double search_pixel_y[5])