<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>danwin.com &#187; stanford</title>
	<atom:link href="https://danwin.com/tag/stanford/feed/" rel="self" type="application/rss+xml" />
	<link>https://danwin.com</link>
	<description>Words, photos, and code by Dan Nguyen. The &#039;g&#039; is mostly silent.</description>
	<lastBuildDate>Thu, 21 Nov 2019 12:29:57 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.39</generator>
	<item>
		<title>Soft-launching Stanford&#8217;s Computational Journalism Lab</title>
		<link>https://danwin.com/2015/10/soft-launching-stanfords-computational-journalism-lab/</link>
		<comments>https://danwin.com/2015/10/soft-launching-stanfords-computational-journalism-lab/#comments</comments>
		<pubDate>Sun, 04 Oct 2015 18:54:20 +0000</pubDate>
		<dc:creator><![CDATA[Dan]]></dc:creator>
				<category><![CDATA[works]]></category>
		<category><![CDATA[computational journalism]]></category>
		<category><![CDATA[stanford]]></category>

		<guid isPermaLink="false">https://danwin.com/?p=2715</guid>
		<description><![CDATA[<p>Last week, my Stanford colleagues and I launched the website for the Computational Journalism Lab. It&#8217;s a soft-launch, as the lab isn&#8217;t a physical lab, but more of an umbrella for the computational work and meetups that we are planning, such as a Computational Journalism conference in 2016, our collaboration in the California Civic Data [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://danwin.com/2015/10/soft-launching-stanfords-computational-journalism-lab/">Soft-launching Stanford&#8217;s Computational Journalism Lab</a> appeared first on <a rel="nofollow" href="https://danwin.com">danwin.com</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>Last week, my Stanford colleagues and I launched the website for the <a href="http://cjlab.stanford.edu/">Computational Journalism Lab</a>. It&#8217;s a soft-launch, as the lab isn&#8217;t a <em>physical</em> lab, but more of an umbrella for the computational work and meetups that we are planning, such as a Computational Journalism conference in 2016, our collaboration in the <a href="http://cjlab.stanford.edu/projects/california-civic-data-coalition/">California Civic Data Coalition</a>, and of course, our <a href="http://cjlab.stanford.edu/initiatives/#courses-section">coursework</a>.</p>
<p>Also, as I&#8217;ve mentioned before on this blog, <a href="http://blog.danwin.com/">pretty much all of my future blogging is going to happen at blog.danwin.com</a>, which is built in Jekyll. Not coincidentally, the Computational Journalism Lab site is also built in <a href="https://jekyllrb.com/">Jekyll</a> &#8212; see <a href="https://github.com/compjolab/cjlab-homepage">its Github here</a>.</p>
<p>The post <a rel="nofollow" href="https://danwin.com/2015/10/soft-launching-stanfords-computational-journalism-lab/">Soft-launching Stanford&#8217;s Computational Journalism Lab</a> appeared first on <a rel="nofollow" href="https://danwin.com">danwin.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://danwin.com/2015/10/soft-launching-stanfords-computational-journalism-lab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to compile OpenCV 2.4.10 on Ubuntu 14.04 and 14.10</title>
		<link>https://danwin.com/2014/12/compile-opencv-2-4-10-ubuntu-14-04-14-10/</link>
		<comments>https://danwin.com/2014/12/compile-opencv-2-4-10-ubuntu-14-04-14-10/#comments</comments>
		<pubDate>Thu, 11 Dec 2014 18:43:03 +0000</pubDate>
		<dc:creator><![CDATA[Dan]]></dc:creator>
				<category><![CDATA[thoughts]]></category>
		<category><![CDATA[opencv]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[stanford]]></category>

		<guid isPermaLink="false">https://danwin.com/?p=2699</guid>
		<description><![CDATA[<p>For my upcoming Computational Methods in the Civic Sphere class at Stanford, I wanted my students to have access to OpenCV so that they could explore computer-vision algorithms, such as face detection with Haar classifiers. On the Stanford FarmShare machines (which run on Ubuntu 13.10), I had trouble getting their installation of OpenCV working, but [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://danwin.com/2014/12/compile-opencv-2-4-10-ubuntu-14-04-14-10/">How to compile OpenCV 2.4.10 on Ubuntu 14.04 and 14.10</a> appeared first on <a rel="nofollow" href="https://danwin.com">danwin.com</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>For my upcoming <a href="http://www.compciv.org/">Computational Methods in the Civic Sphere class at Stanford</a>, I wanted my students to have access to OpenCV so that they could explore computer-vision algorithms, such as <a href="http://docs.opencv.org/modules/objdetect/doc/cascade_classification.html">face detection with Haar classifiers</a>.</p>
<p>On the <a href="https://web.stanford.edu/group/farmshare/cgi-bin/wiki/index.php/Main_Page">Stanford FarmShare machines</a> (which run on Ubuntu 13.10), I had trouble getting their installation of OpenCV working, but was able to use the<br />
<a href="https://store.continuum.io/cshop/anaconda/">Anaconda distribution</a> to install both Python 2.7.8 and <a href="https://conda.binstar.org/menpo">OpenCV 2.4.9.1</a> via the Binstar package repo. </p>
<p>Briefly, here are the instructions:</p>
<ol>
<li>Get the <a href="https://store.continuum.io/cshop/anaconda/">Anaconda download link</a></li>
<li><code>curl (*the-anaconda-URL-script*) -o /tmp/anaconda-install.sh &amp;&amp; bash /tmp/anaconda-install.sh</code></li>
<li><code>conda install binstar</code></li>
<li><code>conda install -c https://conda.binstar.org/menpo opencv</code></li>
</ol>
<p>Note: For Mac users for whom `brew install opencv` isn&#8217;t working: Anaconda worked well enough for me, though I had to install from a different pacakge repo:
<pre>conda install -c https://conda.binstar.org/jjhelmus opencv</pre>
<p>The Anaconda system, which I hadn&#39;t used before but find really convenient, automatically upgrades/downgrades the necessary dependencies (such as <code>numpy</code>).</p>
<p>Using Anaconda works fine on fresh Ubuntu installs (I tested on AWS and Digital Ocean), but I wanted to see if I could compile it from source just in case I couldn&#39;t use Anaconda. This ended up being a very painful time of wading through blog articles and Github issues. Admittedly, I&#39;m not at all an expert at *nix administration, but it&#39;s obvious there&#39;s a lot of incomplete and varying answers out there.</p>
<p>The <a href="https://help.ubuntu.com/community/OpenCV">help.ubuntu.docs on OpenCV are the most extensive</a>, but right at the top, they state: </p>
<blockquote><p>
Ubuntu&#39;s latest incarnation, Utopic Unicorn, comes with a new version of libav, and opencv sources will fail to build with this new library version. Likewise, some packages required by the script no longer exist (libxine-dev, ffmpeg) in the standard repositories. The procedures and script described below will therefore not work at least since Ubuntu 14.10!
</p></blockquote>
<p>The <a href="http://stackoverflow.com/a/9477756/160863">removal of ffmpeg from the official Ubuntu package repo</a> is, from what I can tell, the main source of errors when trying to compile OpenCV for Ubuntu 14.04/14.10. Many of the instructions deal with getting <a href="https://launchpad.net/~jon-severinsson/+archive/ubuntu/ffmpeg">ffmpeg from a personal-package-archive</a> and then trying to build OpenCV. That approach didn&#39;t work for me, but admittedly, I didn&#39;t test out all the possible variables (such as version of ffmpeg).</p>
<p><strong>In the end, what worked</strong> was to simply just set the flag to build without ffmpeg:</p>
<pre><code>  cmake [etc] -D WITH_FFMPEG=OFF
</code></pre>
<p>I&#39;ve <a href="https://gist.github.com/dannguyen/3866388de46f1793dfe1">created a gist to build out all the software I want for my class machines</a>, but here are the relevant parts for OpenCV:</p>
<pre><code>sudo apt-get update &amp;&amp; sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade &amp;&amp; sudo apt-get -y autoremove

# build developer tools. Some of these are probably non-pertinent
sudo apt-get install -y git-core curl zlib1g-dev build-essential \
     libssl-dev libreadline-dev libyaml-dev libsqlite3-dev \
     libxml2-dev libxslt1-dev libcurl4-openssl-dev \
     python-software-properties

# numpy is a dependency for OpenCV, so most of these other
# packages are probably optional
sudo apt-get install -y python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
## Other scientific libraries (obviously not needed for OpenCV)
pip install -U scikit-learn
pip install -U nltk

### opencv from source
# first, installing some utilities
sudo apt-get install -y qt-sdk unzip
OPENCV_VER=2.4.10
curl &quot;http://fossies.org/linux/misc/opencv-${OPENCV_VER}.zip&quot; -o opencv-${OPENCV_VER}.zip
unzip &quot;opencv-${OPENCV_VER}.zip&quot; &amp;&amp; cd &quot;opencv-${OPENCV_VER}&quot;
mkdir build &amp;&amp; cd build
# build without ffmpeg
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON \
      -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON \
      -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON \
      -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON \
      -D WITH_FFMPEG=OFF ..
</code></pre>
<p>A recurring issue I had come across &ndash; I didn&#39;t test it myself, but just saw it in the variety of speculation regarding the difficulty of building OpenCV &ndash; is that building with a Python <em>other than the system&#39;s Python</em> would cause problems. So, for what it&#39;s worth, the above process works with 14.04&#39;s Python 2.7.6, and 14.10&#39;s 2.7.8. I&#39;m not much of a Python user myself so I don&#39;t know much about best practices regarding environment&#8230;<a href="https://github.com/yyuu/pyenv">pyenv works pretty effortlessly</a> (that is, it works just like rbenv), but I didn&#39;t try it in relation to building OpenCV.</p>
<p>Also, this isn&#39;t the bare minimum&#8230;I&#39;m not sure what dev tools or which <code>cmake</code> flags are are absolutely needed, or if <code>qt-sdk</code> is needed if you don&#39;t build with Qt support. But it works, so hopefully anyone Googling this issue will be able to make some progress.</p>
<p>Note: Other things I tried that did not work on clean installs of Ubuntu 14.04/14.10:</p>
<ul>
<li><a href="http://www.samontab.com/web/2014/06/installing-opencv-2-4-9-in-ubuntu-14-04-lts/">Sebastian Montabone&#39;s writeup</a></li>
<li><code>sudo apt-get build-dep opencv</code></li>
<li><code>sudo apt-get install libopencv-dev</code> (<a href="http://stackoverflow.com/questions/26592577/installing-opencv-in-ubuntu-14-10">as per StackOverflow</a>)</li>
</ul>
<p> The Python code needed to do simple face-detection looks something like this (based off of examples from <a href="http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html">OpenCV-Python</a> and <a href="https://www.pyimagesearch.com/practical-python-opencv/">Practical Python and OpenCV</a>: </p>
<p>(You can <a href="https://github.com/Itseez/opencv/tree/master/data/haarcascades">find pre=built XML classifiers at the OpenCV repo</a>)</p>
<pre><code>
import cv2
face_cascade_path = '/YOUR/PATH/TO/haarcascade_frontalface_default.xml'
face_cascade = cv2.CascadeClassifier(face_cascade_path)

scale_factor = 1.1
min_neighbors = 3
min_size = (30, 30)
flags = cv2.cv.CV_HAAR_SCALE_IMAGE

# load the image
image_path = "YOUR/PATH/TO/image.jpg"
image = cv2.imread(image_path)

# this does the work
rects = face_cascade.detectMultiScale(image, scaleFactor = scale_factor,
  minNeighbors = min_neighbors, minSize = min_size, flags = flags)

for( x, y, w, h ) in rects:
  cv2.rectangle(image, (x, y), (x + w, y + h), (255, 255, 0), 2)

cv2.imwrite("YOUR/PATH/TO/output.jpg", image)
</code></pre>
<p>The post <a rel="nofollow" href="https://danwin.com/2014/12/compile-opencv-2-4-10-ubuntu-14-04-14-10/">How to compile OpenCV 2.4.10 on Ubuntu 14.04 and 14.10</a> appeared first on <a rel="nofollow" href="https://danwin.com">danwin.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://danwin.com/2014/12/compile-opencv-2-4-10-ubuntu-14-04-14-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
