Fixing the screen flickering on a Dell Inspiron N5720 (and maybe many others)

I have a Dell Inspiron N5720 and was quite happy with it. After installing Windows 8 some mysterious screen flickering appeared. I ignored it for a while, but I noticed that it only happens when not plugged in. So only a few possibilities are left:

  • The graphics card/display/something in between is broken
  • The battery is defect
  • Something is wrong with the drivers

Checking the first two possibilities would’ve been too time consuming without a real result. And it’s kind of unlikely that the battery and/or graphics card broke just as I installed Windows 8. And the fact that it only happens when on battery is also a good hint, as this indicated that it could be something with the power saving settings (spoiler: it was).

A Dell Inspiron N5720 has a nVidia GT 630M and an Intel HD Graphics 4000. Let’s see what the Intel Graphics Control panel looks like. To open it, follow these instructions.

Select Advanced mode.

Go to the Power menu and change the power source to “On battery”. Now uncheck the little check box that says “Display Refresh Rate Switch”. Apply. OK. And you’re done.
And that’s it. Never had another screen flicker after that. I assume that this could solve the screen flickering on most, if not all laptops with an Intel HD Graphics 4000. Hope it helps!
EDIT:
It seems like Windows 8.1 isn’t kind to us. Among other problems, the flickering, even if fixed before the update, returns once the update is complete. The option that prevents flickering still exists, it’s just kind of hidden now. I fixed it this way:
  • Right click on desktop.Go to “Graphics settings” or however they call it now (they forcefully localize this stuff now..) This should appear:

Power Settings

  • Click on Power, then on “On Battery”.

New Intel HD panel

  • Switch it to maximum performance, and turn off the “Display power saving technology”.

I hope this helps. I haven’t had flickers since the update after changing this.

Setting everything up for OpenCV – Raspberry Pi

Setting OpenCV up on the Raspberry Pi took me two attempts and about 20 hours. I’m writing this guide so others don’t have to go through all the problems. I will mainly use OpenCV with Python; I haven’t tested it with C/C++.

You will need:
  1. A Raspberry Pi
  2. A 3gb or more SD Card with the Raspbian image
  3. A working Internet connection
  4. A way to see Rapsi’s desktop environment (for testing)
  5. Patience
Optional:
  1. PuTTY

Attempt #1 – Following other guides

Googling about OpenCV and Raspberry Pi leads to a few guides how to set it up (this and this). They helped a lot, but they didn’t fully work for me. However, without them I wouldn’t be writing this right now.

First of all, you need to install all dependencies. You can get most of them by running the following commands:

sudo apt-get -y install build-essential cmake cmake-qt-gui pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools

sudo apt-get -y install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs ffmpeg libavcodec-dev libavcodec53 libavformat53 libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils swig libv4l-0 libv4l-dev python-numpy libpython2.6 python-dev python2.6-dev libgtk2.0-dev pkg-config

And that’s about it from the other guides that we can use. I’m not sure if we really need Python 2.6, as 2.7 comes preinstalled. I wasn’t in the mood for testing at that time. Either way, I followed the guides, downloaded the version they recommended, run CMake, started building, and around 4.5 hours later I had build something. Sadly, it didn’t work. As it later turned out, it had something to to with the version of ffmpeg (it was too new).

Attempt #2 – Figuring it out by myself

So.. what now? First, let’s download the latest version of OpenCV (v2.4.2 as of writing this).

wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.2/OpenCV-2.4.2.tar.bz2/download

It’s quite heavy; it will take some time to download. It downloaded for me in a file named “download”. I’m not quite sure why it wasn’t named properly, but whatever. Let’s unpack it:

tar -xvjpf download

(or whatever name it has on your machine)

We go inside the new directory that we got with unpacking, and make a new one within it. I named my “build”.

cd OpenCV-2.4.2/
mkdir build
cd build

And, now we are ready to build! Or not. Yeah, we aren’t ready at all. We need to run CMake and see what is says. Here is now a difference to the other guides I found – we need to replace BUILD_PYTHON_SUPPORT with BUILD_NEW_PYTHON_SUPPORT. Run:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..

As I wasn’t planning on writing this, I haven’t backed my first CMake output up. There will be some tests run, and some will fail. But that’s ok! Watch carefully and note the names of the missing libs. Install everything that’s missing. For example, if it says that it can’t find gtk+-2.0, install it (sudo apt-get install gtk+-2.0). I had to install a few things, including some Python modules. If you can’t figure out the package name of a module, just Google it. My CMake output looked somewhat like this before building:

GUI:
– GTK+ 2.x: YES
– GThread: YES

– Media I/O:
– ZLib: YES
– JPEG: TRUE
– PNG: TRUE
– TIFF: TRUE
– JPEG 2000: TRUE
– OpenEXR: NO
– OpenNI: NO
– OpenNI PrimeSensor Modules: NO
– XIMEA: NO

– Video I/O:
– DC1394 1.x: NO
– DC1394 2.x: YES
– FFMPEG: YES
– codec: YES
– format: YES
– util: YES
– swscale: YES
– gentoo-style: YES
– GStreamer: YES
– UniCap: NO
– PvAPI: NO
– V4L/V4L2: Using libv4l
– Xine: NO

– Other third-party libraries:
– Use IPP: NO
– Use TBB: NO
– Use ThreadingFramework: NO
– Use Cuda: NO
– Use Eigen: NO

– Interfaces:
– Python: YES
– Python interpreter: /usr/bin/python -B (ver 2.7)
– Python numpy: YES
– Java: NO

– Documentation:
– Sphinx: /usr/bin/sphinx-build (ver 1.1.3)
– PdfLaTeX compiler: NO
– Build Documentation: YES (only HTML without math formulas)

As I already said, just read carefully and install the missing pieces.

When you install everything you need, it’s time to build. Simply run:

make

This will take a really, really long time. Long as in 10 hours and 4 minutes. Just a tip: don’t think it froze. It will look sometimes as if it froze and there is no hope. Just wait. When it finishes, run the last command:

make install

Let it do it’s magic. Congratulations, you just compiled OpenCV on your Raspberry Pi.

Try it out

Start your desktop environment. Open up the Terminal and go to OpenCV-2.4.2/samples/python. Run a sample:

python drawing.py

And it should work. I went ahead and tried to access the webcam stream, and:

I hope this guide will help you. If you have any question, feel free to ask! Happy coding!

Setting everything up for OpenCV

Hello!

I’ve always be fascinated with Computer Vision. I made a few prototypes, tested a few things and it was fun. It weren’t the most optimal solutions, but they worked. I always knew that OpenCV exists, but never really bothered to try it out. Well, until now.

It turns out setting this beast up isn’t really as easy as I thought. So I decided to write a few guides how to do it. I will use it primary on the Raspberry Pi, and programming will most likely take place on my Windows machine in Python.

  1.  Setting everything up for OpenCV – Raspberry Pi on Raspbian
  2.  Setting everything up for OpenCV – Windows 7

Feel free to leave a comment!

So here we are again..

.. it’s always such a pleasure :D

So here is another attempt to write a blog. I finally made my mind up – no super boring stuff, no final exam stuff or anything like that. This is now going to be a place where I write about things I discover and want to share with the world. There won’t be a strict schedule of writing – I will write something as it hits me.

As you may have noticed, English isn’t my native language, so there are going to be a lot of mistakes. Feel free to satisfy your grammar nazi needs! All corrections are welcome; they help to improve. If you discover any error in the content, I humbly ask you to point it out and correct it it the comments.

To end this post, here’s a little bit about me:

My name is Denis and I’m a Computer Science student. I’m fascinated by technology and science, and I want to share that fascination with the world. I’m making games and semi-useful apps in my spare time. And that’s about it. If you have any questions, feel free to ask!