﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=%E5%88%A9%E7%94%A8%E8%80%85%3ASftrabbit%2FGSoC_2013%2FDocumentation%2FFirst_Week_Notes</id>
	<title>利用者:Sftrabbit/GSoC 2013/Documentation/First Week Notes - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.blender.jp/index.php?action=history&amp;feed=atom&amp;title=%E5%88%A9%E7%94%A8%E8%80%85%3ASftrabbit%2FGSoC_2013%2FDocumentation%2FFirst_Week_Notes"/>
	<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Sftrabbit/GSoC_2013/Documentation/First_Week_Notes&amp;action=history"/>
	<updated>2026-05-19T20:49:34Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Sftrabbit/GSoC_2013/Documentation/First_Week_Notes&amp;diff=143711&amp;oldid=prev</id>
		<title>Yamyam: 1版 をインポートしました</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Sftrabbit/GSoC_2013/Documentation/First_Week_Notes&amp;diff=143711&amp;oldid=prev"/>
		<updated>2018-06-28T21:04:25Z</updated>

		<summary type="html">&lt;p&gt;1版 をインポートしました&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;2018年6月28日 (木) 21:04時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;ja&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(相違点なし)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Yamyam</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Sftrabbit/GSoC_2013/Documentation/First_Week_Notes&amp;diff=143710&amp;oldid=prev</id>
		<title>wiki&gt;Sftrabbit: Created page with &quot;=First Week Notes=  ==Getting started==  On the first day, I was a little unsure of where I was heading yet, so I spent the day getting up to speed with recent mailings, started ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.blender.jp/index.php?title=%E5%88%A9%E7%94%A8%E8%80%85:Sftrabbit/GSoC_2013/Documentation/First_Week_Notes&amp;diff=143710&amp;oldid=prev"/>
		<updated>2013-09-22T09:41:06Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;=First Week Notes=  ==Getting started==  On the first day, I was a little unsure of where I was heading yet, so I spent the day getting up to speed with recent mailings, started ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=First Week Notes=&lt;br /&gt;
&lt;br /&gt;
==Getting started==&lt;br /&gt;
&lt;br /&gt;
On the first day, I was a little unsure of where I was heading yet, so I spent the day getting up to speed with recent mailings, started making notes, bookmarking useful information, etc. It was useful to write a little to-do list based on the “Getting Started” email that Ton had sent out earlier. I also made notes of people and their IRC nicks so I could remember who was who. I synced my branch with the trunk so I could start working from the latest code. It was a little nerve-wracking to do my first commit, in case I accidentally destroyed the entire SVN repository, but it was fine.&lt;br /&gt;
&lt;br /&gt;
==First task==&lt;br /&gt;
&lt;br /&gt;
I spoke with Keir in the evening. We agreed that it'd be nice to tackle the work in small chunks rather than one big commit at the end. That's better for me as I can gradually get used to everything.&lt;br /&gt;
&lt;br /&gt;
Then I got my first task: add constraints to the focal length for bundle adjustment. The user should be able to specify minimum and maximum constraints on the camera focal length and the bundle adjuster will only optimize within this range. This would require changes to the UI, [https://code.google.com/p/libmv/ libmv], and interfacing with [https://code.google.com/p/ceres-solver/ Ceres Solver].&lt;br /&gt;
&lt;br /&gt;
==Ceres Solver==&lt;br /&gt;
&lt;br /&gt;
The [https://code.google.com/p/ceres-solver/ Ceres Solver] library is used to solve non-linear least squares problems. The process of motion tracking can be seen as such an optimization problem, where the parameter space is the position, orientation, and intrinsic properties of the camera (or other objects you want to track). To learn how to use Ceres, I followed the official [http://homes.cs.washington.edu/~sagarwal/ceres-solver/tutorial.html#chapter-tutorial tutorial] and compiled a few simple examples. It's very cool and also very easy to use.&lt;br /&gt;
&lt;br /&gt;
==Blender architecture====&lt;br /&gt;
&lt;br /&gt;
I had to learn a lot about the Blender architecture before I could get started with coding. My approach was to look specifically at everything that is involved in camera solving, from clicking the button to getting a result, so I would be ready to tackle the task. For two days or so I read through the source and learnt about the following things:&lt;br /&gt;
&lt;br /&gt;
# DNA - Describes how data is stored in the .blend files and in memory once the file is loaded using C structs (with some packing restrictions). For motion tracking (and the rest of the clip space), the relevant DNA structs are defined in &amp;lt;code&amp;gt;source/blender/makesdna/DNA_movieclip.c&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;DNA_tracking_types.c&amp;lt;/code&amp;gt;.&lt;br /&gt;
# RNA - Provides a more friendly interface to the underlying data. For motion tracking, take a look at &amp;lt;code&amp;gt;source/blender/makesrna/intern/rna_movieclip.c&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rna_tracking.c&amp;lt;/code&amp;gt;&lt;br /&gt;
# Python UI - The user interface for the clip space is created in &amp;lt;code&amp;gt;release/scripts/startup/bl_ui/space_clip.py&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;CLIP_PT_tools_solve&amp;lt;/code&amp;gt; class describes the solving panel. It's worth noting that the HT, PT, UL, and MT appear to stand for Header Type, Panel Type, Unordered List, and Menu Type respectively, although this isn't documented anywhere.&lt;br /&gt;
# Operators - In the UI, &amp;lt;code&amp;gt;col.operator(&amp;quot;clip.solve_camera&amp;quot;, ...)&amp;lt;/code&amp;gt; is used to create a button. This button will invoke the operator identified by &amp;lt;code&amp;gt;clip.solve_camera&amp;lt;/code&amp;gt;. Operators are registered by the clip space in the &amp;lt;code&amp;gt;clip_operatortypes&amp;lt;/code&amp;gt; function in &amp;lt;code&amp;gt;source/blender/editors/space_clip/space_clip.c&amp;lt;/code&amp;gt; file. In this case, the &amp;lt;code&amp;gt;CLIP_OT_solve_camera&amp;lt;/code&amp;gt; function is registered. The operator identifier in Python is automatically translated from &amp;lt;code&amp;gt;some.operator&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;SOME_OT_operator&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;CLIP_OT_solve_camera&amp;lt;/code&amp;gt; function simply provides some callbacks - the &amp;lt;code&amp;gt;invoke&amp;lt;/code&amp;gt; callback is called when the button is pressed.&lt;br /&gt;
# Jobs - The &amp;lt;code&amp;gt;solve_camera_invoke&amp;lt;/code&amp;gt; function creates a &amp;lt;code&amp;gt;wmJob&amp;lt;/code&amp;gt; with an associated &amp;lt;code&amp;gt;SolveCameraJob&amp;lt;/code&amp;gt; object for storing data needed for the job. The kernel functions &amp;lt;code&amp;gt;BKE_tracking_reconstruction_check&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;BKE_tracking_reconstruction_context_new&amp;lt;/code&amp;gt; are used to initialise this data. The &amp;lt;code&amp;gt;solve_camera_startjob&amp;lt;/code&amp;gt; function is set as the start function for the job, which calls &amp;lt;code&amp;gt;BKE_tracking_reconstruction_solve&amp;lt;/code&amp;gt;.&lt;br /&gt;
# libmv - The &amp;lt;code&amp;gt;BKE_tracking_reconstruction_solve&amp;lt;/code&amp;gt; function passes objects containing the relevant options to &amp;lt;code&amp;gt;libmv_solveReconstruction&amp;lt;/code&amp;gt;, which is part of the C API for libmv defined in &amp;lt;code&amp;gt;extern/libmv/libmv-capi.cc&amp;lt;/code&amp;gt;. The libmv library itself is written in C++ and interfaces with Ceres Solver.&lt;br /&gt;
&lt;br /&gt;
It was very useful to write code traces and diagrams to help with understanding the flow of code.&lt;br /&gt;
&lt;br /&gt;
==User interface==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;libmv_solveReconstruction&amp;lt;/code&amp;gt; function calls &amp;lt;code&amp;gt;libmv::EuclideanBundleCommonIntrinsics&amp;lt;/code&amp;gt; twice. The first time, &amp;lt;code&amp;gt;BUNDLE_NO_INTRINSICS&amp;lt;/code&amp;gt; is passed, causing it to treat the camera's intrinsic parameters as constant. The second call only occurs if the user has selected parameters to refine in the user interface, and those selected parameters are optimized over. This means that the bundle adjuster may find a better solution if it is allowed to vary these parameters slightly.&lt;br /&gt;
&lt;br /&gt;
My task is to allow the use to specify a minimum and maximum focal length so that, when the focal length has been selected for refinement, it is only refined within this range. I created a mock-up of the user interface I expected to be most appropriate for this:&lt;br /&gt;
&lt;br /&gt;
[[File:focal-length-constraint-mockup.png|none|frame|A mock-up of the user interface for constraining the refinement of focal length.]]&lt;br /&gt;
&lt;br /&gt;
==Applying the constraint==&lt;br /&gt;
&lt;br /&gt;
While waiting for feedback on the UI design, I started coding the constraint on the libmv side. Since Ceres Solver works with unconstrained parameters, the focal length parameter needs to be transformed so that regardless of the optimized value, the transformed value will be in the given range. This can be done by using the following transformation:&lt;br /&gt;
&lt;br /&gt;
 actual_focal = min + (max - min) * (1 + sin(bundled_focal))/2&lt;/div&gt;</summary>
		<author><name>wiki&gt;Sftrabbit</name></author>
		
	</entry>
</feed>