42 # define CACHE_PRINTF(...) printf(__VA_ARGS__)
44 # define CACHE_PRINTF(...)
59 map->is_camera = is_camera;
61 map->num_tracks = num_tracks;
62 map->customdata_size = customdata_size;
66 if (customdata_size) {
67 map->customdata =
MEM_callocN(customdata_size * num_tracks,
"TracksMap customdata");
79 return map->num_tracks;
87 *track = &
map->tracks[index];
89 if (
map->customdata) {
90 *customdata = &
map->customdata[index *
map->customdata_size];
100 map->tracks[
map->ptr] = new_track;
103 memcpy(&
map->customdata[
map->ptr *
map->customdata_size], customdata,
map->customdata_size);
117 if (
map->is_camera) {
118 old_tracks = &tracking->
tracks;
128 old_tracks = &
object->tracks;
135 for (
int a = 0;
a <
map->num_tracks;
a++) {
137 bool mapped_to_old =
false;
139 track = &
map->tracks[
a];
163 mapped_to_old =
true;
167 if (mapped_to_old ==
false) {
178 track = old_tracks->
first;
200 sizeof(track->
name));
205 *old_tracks = new_tracks;
212 for (
int i = 0; i <
map->num_tracks; i++) {
213 if (
map->customdata && customdata_free) {
214 customdata_free(&
map->customdata[i *
map->customdata_size]);
220 if (
map->customdata) {
245 const float unified_coords[2],
246 float pixel_coords[2])
248 pixel_coords[0] = unified_coords[0] * frame_width;
249 pixel_coords[1] = unified_coords[1] * frame_height;
253 const float marker_unified_coords[2],
254 float frame_unified_coords[2])
256 frame_unified_coords[0] = marker_unified_coords[0] + marker->
pos[0];
257 frame_unified_coords[1] = marker_unified_coords[1] + marker->
pos[1];
263 const float marker_unified_coords[2],
264 float frame_pixel_coords[2])
267 unified_to_pixel(frame_width, frame_height, frame_pixel_coords, frame_pixel_coords);
273 float frame_pixel[2])
277 frame_width, frame_height, marker, marker->
search_min, frame_pixel);
278 frame_pixel[0] = (int)frame_pixel[0];
279 frame_pixel[1] = (int)frame_pixel[1];
284 const float pixel_coords[2],
285 float unified_coords[2])
287 unified_coords[0] = pixel_coords[0] / frame_width;
288 unified_coords[1] = pixel_coords[1] / frame_height;
294 const float marker_unified[2],
295 float search_pixel[2])
297 float frame_pixel[2];
298 float search_origin_frame_pixel[2];
301 frame_width, frame_height, marker, marker_unified, frame_pixel);
303 frame_width, frame_height, marker, search_origin_frame_pixel);
304 sub_v2_v2v2(search_pixel, frame_pixel, search_origin_frame_pixel);
310 const float search_pixel[2],
311 float marker_unified[2])
313 float frame_unified[2];
314 float search_origin_frame_pixel[2];
317 frame_width, frame_height, marker, search_origin_frame_pixel);
318 add_v2_v2v2(frame_unified, search_pixel, search_origin_frame_pixel);
328 double search_pixel_x[5],
329 double search_pixel_y[5])
331 float unified_coords[2];
332 float pixel_coords[2];
335 for (
int i = 0; i < 4; i++) {
337 frame_width, frame_height, marker, marker->
pattern_corners[i], pixel_coords);
338 search_pixel_x[i] = pixel_coords[0] - 0.5f;
339 search_pixel_y[i] = pixel_coords[1] - 0.5f;
343 unified_coords[0] = 0.0f;
344 unified_coords[1] = 0.0f;
347 search_pixel_x[4] = pixel_coords[0] - 0.5f;
348 search_pixel_y[4] = pixel_coords[1] - 0.5f;
354 const double search_pixel_x[5],
355 const double search_pixel_y[5])
357 float marker_unified[2];
358 float search_pixel[2];
361 for (
int i = 0; i < 4; i++) {
362 search_pixel[0] = search_pixel_x[i] + 0.5;
363 search_pixel[1] = search_pixel_y[i] + 0.5;
365 frame_width, frame_height, marker, search_pixel, marker->
pattern_corners[i]);
369 search_pixel[0] = search_pixel_x[4] + 0.5;
370 search_pixel[1] = search_pixel_y[4] + 0.5;
377 for (
int i = 0; i < 4; i++) {
382 marker->
pos[0] += marker_unified[0];
383 marker->
pos[1] += marker_unified[1];
399 marker_new = *ref_marker;
418 switch (
camera->distortion_model) {
500 int calibration_width,
501 int calibration_height,
516 camera_intrinsics_options->
image_width = calibration_width;
517 camera_intrinsics_options->
image_height = (int)(calibration_height * aspy);
542 while (
a >= 0 && a < track->markersnr) {
543 int next = backwards ?
a + 1 :
a - 1;
544 bool is_keyframed =
false;
548 if (
next >= 0 && next < track->markersnr) {
557 if (next_marker ==
NULL) {
564 if (marker_keyed_fallback ==
NULL) {
565 marker_keyed_fallback = cur_marker;
569 if (marker_keyed_fallback ==
NULL) {
570 marker_keyed_fallback = cur_marker;
578 marker_keyed = cur_marker;
586 if (marker_keyed ==
NULL) {
587 marker_keyed = marker_keyed_fallback;
610 clip = accessor->
clips[clip_index];
631 const size_t size = (size_t)grayscale->
x * (
size_t)grayscale->
y *
sizeof(
float);
637 for (
int i = 0; i < grayscale->
x * grayscale->
y; i++) {
640 grayscale->
rect_float[i] = 0.2126f * pixel[0] + 0.7152f * pixel[1] + 0.0722f * pixel[2];
651 float_image->
width = ibuf->
x;
679 CACHE_PRINTF(
"Calculate new buffer for frame %d\n", frame);
682 if (orig_ibuf ==
NULL) {
687 if (region !=
NULL) {
694 int clamped_origin_x =
max_ii((
int)region->
min[0], 0),
695 clamped_origin_y =
max_ii((
int)region->
min[1], 0);
696 int dst_offset_x = clamped_origin_x - (int)region->
min[0],
697 dst_offset_y = clamped_origin_y - (
int)region->
min[1];
698 int clamped_width =
width - dst_offset_x, clamped_height =
height - dst_offset_y;
699 clamped_width =
min_ii(clamped_width, orig_ibuf->
x - clamped_origin_x);
700 clamped_height =
min_ii(clamped_height, orig_ibuf->
y - clamped_origin_y);
719 for (
int y = 0;
y < clamped_height;
y++) {
720 for (
int x = 0;
x < clamped_width;
x++) {
721 int src_x =
x + clamped_origin_x, src_y =
y + clamped_origin_y;
722 int dst_x =
x + dst_offset_x, dst_y =
y + dst_offset_y;
723 int dst_index = (dst_y *
width + dst_x) * 4,
724 src_index = (src_y * orig_ibuf->
x + src_x) * 4;
726 (
unsigned char *)orig_ibuf->
rect + src_index);
741 final_ibuf = orig_ibuf;
745 if (final_ibuf == orig_ibuf) {
748 IMB_scaleImBuf(final_ibuf, orig_ibuf->
x / (1 << downscale), orig_ibuf->
y / (1 << downscale));
755 if (final_ibuf != orig_ibuf) {
770 if (final_ibuf != orig_ibuf) {
774 final_ibuf = grayscale_ibuf;
781 if (final_ibuf == orig_ibuf) {
803 BLI_assert(clip_index >= 0 && clip_index < accessor->num_clips);
834 float **r_destination,
841 BLI_assert(track_index < accessor->num_tracks);
857 int frame_width, frame_height;
861 const float region_min[2] = {
862 region->
min[0] - marker->
pos[0] * frame_width,
863 region->
min[1] - marker->
pos[1] * frame_height,
865 const float region_max[2] = {
866 region->
max[0] - marker->
pos[0] * frame_width,
867 region->
max[1] - marker->
pos[1] * frame_height,
870 frame_width, frame_height, region_min, region_max, track);
871 *r_width = region->
max[0] - region->
min[0];
872 *r_height = region->
max[1] - region->
min[1];
873 return *r_destination;
878 if (cache_key !=
NULL) {
879 float *
mask = (
float *)cache_key;
890 "tracking image accessor");
typedef float(TangentPoint)[2]
void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr)
void BKE_movieclip_get_size(struct MovieClip *clip, struct MovieClipUser *user, int *width, int *height)
struct ImBuf * BKE_movieclip_get_ibuf(struct MovieClip *clip, struct MovieClipUser *user)
float BKE_movieclip_remap_clip_to_scene_frame(const struct MovieClip *clip, float framenr)
struct MovieTrackingTrack * BKE_tracking_track_duplicate(struct MovieTrackingTrack *track)
struct MovieTrackingMarker * BKE_tracking_marker_insert(struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker)
struct MovieTrackingObject * BKE_tracking_object_add(struct MovieTracking *tracking, const char *name)
struct MovieTrackingMarker * BKE_tracking_marker_get_exact(struct MovieTrackingTrack *track, int framenr)
void BKE_tracking_track_free(struct MovieTrackingTrack *track)
bool BKE_tracking_track_has_marker_at_frame(struct MovieTrackingTrack *track, int framenr)
struct MovieTrackingObject * BKE_tracking_object_get_named(struct MovieTracking *tracking, const char *name)
struct MovieTrackingMarker * BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr)
#define BLI_assert_msg(a, msg)
bool BLI_ghash_reinsert(GHash *gh, void *key, void *val, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
bool BLI_uniquename(struct ListBase *list, void *vlink, const char *defname, char delim, int name_offset, size_t name_len)
void BLI_thread_unlock(int type)
void BLI_thread_lock(int type)
int BLI_system_thread_count(void)
void BLI_spin_init(SpinLock *spin)
void BLI_spin_unlock(SpinLock *spin)
void BLI_spin_lock(SpinLock *spin)
void BLI_spin_end(SpinLock *spin)
#define CTX_DATA_(context, msgid)
#define BLT_I18NCONTEXT_ID_MOVIECLIP
typedef double(DMatrix)[4][4]
@ MCLIP_PROXY_RENDER_SIZE_FULL
@ TRACK_ALGORITHM_FLAG_USE_MASK
@ TRACKING_DISTORTION_MODEL_DIVISION
@ TRACKING_DISTORTION_MODEL_POLYNOMIAL
@ TRACKING_DISTORTION_MODEL_NUKE
@ TRACKING_DISTORTION_MODEL_BROWN
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
void IMB_float_from_rect(struct ImBuf *ibuf)
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
struct ImBuf * IMB_dupImBuf(const struct ImBuf *ibuf1)
void IMB_rectcpy(struct ImBuf *dbuf, const struct ImBuf *sbuf, int destx, int desty, int srcx, int srcy, int width, int height)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between camera
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void libmv_FrameAccessorDestroy(libmv_FrameAccessor *frame_accessor)
void libmv_frameAccessorgetTransformRun(const libmv_FrameTransform *transform, const libmv_FloatImage *input_image, libmv_FloatImage *output_image)
libmv_FrameAccessor * libmv_FrameAccessorNew(libmv_FrameAccessorUserData *user_data, libmv_GetImageCallback get_image_callback, libmv_ReleaseImageCallback release_image_callback, libmv_GetMaskForTrackCallback get_mask_for_track_callback, libmv_ReleaseMaskCallback release_mask_callback)
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
@ LIBMV_DISTORTION_MODEL_POLYNOMIAL
@ LIBMV_DISTORTION_MODEL_NUKE
@ LIBMV_DISTORTION_MODEL_BROWN
@ LIBMV_DISTORTION_MODEL_DIVISION
struct libmv_FrameTransform libmv_FrameTransform
struct libmv_FrameAccessorUserData libmv_FrameAccessorUserData
void libmv_floatImageDestroy(libmv_FloatImage *image)
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
SocketIndexByIdentifierMap * map
float pattern_corners[4][2]
MovieTrackingMarker * markers
struct MovieTrackingTrack * next
struct MovieTrackingTrack * prev
MovieTrackingCamera camera
struct MovieTrackingTrack ** tracks
struct MovieClip * clips[MAX_ACCESSOR_CLIP]
struct libmv_FrameAccessor * libmv_accessor
float * tracking_track_get_mask_for_region(int frame_width, int frame_height, const float region_min[2], const float region_max[2], MovieTrackingTrack *track)
#define MAX_ACCESSOR_CLIP
static void accessor_release_image_callback(libmv_CacheKey cache_key)
static void pixel_to_unified(int frame_width, int frame_height, const float pixel_coords[2], float unified_coords[2])
static ImBuf * float_image_to_ibuf(libmv_FloatImage *float_image)
static void unified_to_pixel(int frame_width, int frame_height, const float unified_coords[2], float pixel_coords[2])
static libmv_CacheKey accessor_get_mask_for_track_callback(libmv_FrameAccessorUserData *user_data, int clip_index, int frame, int track_index, const libmv_Region *region, float **r_destination, int *r_width, int *r_height)
void tracking_marker_insert_disabled(MovieTrackingTrack *track, const MovieTrackingMarker *ref_marker, bool before, bool overwrite)
static void search_pixel_to_marker_unified(int frame_width, int frame_height, const MovieTrackingMarker *marker, const float search_pixel[2], float marker_unified[2])
int tracks_map_get_size(TracksMap *map)
static ImBuf * accessor_get_preprocessed_ibuf(TrackingImageAccessor *accessor, int clip_index, int frame)
static void ibuf_to_float_image(const ImBuf *ibuf, libmv_FloatImage *float_image)
static libmv_CacheKey accessor_get_image_callback(struct libmv_FrameAccessorUserData *user_data, int clip_index, int frame, libmv_InputMode input_mode, int downscale, const libmv_Region *region, const libmv_FrameTransform *transform, float **destination, int *width, int *height, int *channels)
static void marker_unified_to_frame_pixel_coordinates(int frame_width, int frame_height, const MovieTrackingMarker *marker, const float marker_unified_coords[2], float frame_pixel_coords[2])
static void marker_unified_to_search_pixel(int frame_width, int frame_height, const MovieTrackingMarker *marker, const float marker_unified[2], float search_pixel[2])
static ImBuf * make_grayscale_ibuf_copy(ImBuf *ibuf)
void tracking_cameraIntrinscisOptionsFromTracking(MovieTracking *tracking, int calibration_width, int calibration_height, libmv_CameraIntrinsicsOptions *camera_intrinsics_options)
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])
void tracks_map_get_indexed_element(TracksMap *map, int index, MovieTrackingTrack **track, void **customdata)
void tracks_map_free(TracksMap *map, void(*customdata_free)(void *customdata))
static void distortion_model_parameters_from_options(const libmv_CameraIntrinsicsOptions *camera_intrinsics_options, MovieTrackingCamera *camera)
MovieTrackingMarker * tracking_get_keyframed_marker(MovieTrackingTrack *track, int current_frame, bool backwards)
TrackingImageAccessor * tracking_image_accessor_new(MovieClip *clips[MAX_ACCESSOR_CLIP], int num_clips, MovieTrackingTrack **tracks, int num_tracks)
static void marker_to_frame_unified(const MovieTrackingMarker *marker, const float marker_unified_coords[2], float frame_unified_coords[2])
#define CACHE_PRINTF(...)
void tracking_trackingCameraFromIntrinscisOptions(MovieTracking *tracking, const libmv_CameraIntrinsicsOptions *camera_intrinsics_options)
static void distortion_model_parameters_from_tracking(const MovieTrackingCamera *camera, libmv_CameraIntrinsicsOptions *camera_intrinsics_options)
void tracks_map_insert(TracksMap *map, MovieTrackingTrack *track, void *customdata)
void tracking_image_accessor_destroy(TrackingImageAccessor *accessor)
TracksMap * tracks_map_new(const char *object_name, bool is_camera, int num_tracks, int customdata_size)
static void accessor_release_mask_callback(libmv_CacheKey cache_key)
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])
static ImBuf * accessor_get_ibuf(TrackingImageAccessor *accessor, int clip_index, int frame, libmv_InputMode input_mode, int downscale, const libmv_Region *region, const libmv_FrameTransform *transform)
void tracking_get_search_origin_frame_pixel(int frame_width, int frame_height, const MovieTrackingMarker *marker, float frame_pixel[2])
void tracks_map_merge(TracksMap *map, MovieTracking *tracking)