Coder Social home page Coder Social logo

pcv's People

Contributors

jdagilliland avatar jesolem avatar nico avatar sampwing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pcv's Issues

(question) Haffine_from_points , image_in_image

Hi, I'm student studying your book
thank you for your good teaching

I have one question ( book page 56,58 , chapter 3)

In the definition of Haffine_from_points(fp,tp),
the first argument is 'fp' and the second argument is 'tp'

but in the definition of image_in_image,
you switched the argument of Haffine_from_points function
in this case, first argument is 'tp' and second argument is 'fp'

i can't match definition and application of Haffine_from_points

Why did you do that?

thank you for your reading, if you don't understand, i'll rewrite

Panoramio no longer available

When trying to follow your example to download the images of the White House in ch2_download_panoramio.py, I get a ValueError:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-5652052d9722> in <module>()
----> 1 j = json.loads(c.read())

/Users/athair/anaconda2/lib/python2.7/json/__init__.pyc in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    337             parse_int is None and parse_float is None and
    338             parse_constant is None and object_pairs_hook is None and not kw):
--> 339         return _default_decoder.decode(s)
    340     if cls is None:
    341         cls = JSONDecoder

/Users/athair/anaconda2/lib/python2.7/json/decoder.pyc in decode(self, s, _w)
    362 
    363         """
--> 364         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    365         end = _w(s, end).end()
    366         if end != len(s):

/Users/athair/anaconda2/lib/python2.7/json/decoder.pyc in raw_decode(self, s, idx)
    380             obj, end = self.scan_once(s, idx)
    381         except StopIteration:
--> 382             raise ValueError("No JSON object could be decoded")
    383         return obj, end

ValueError: No JSON object could be decoded

I imagine this is due to the fact that Panoramio was taken down in November, 2016. Could you add the downloaded files to the pcv_data.zip so we can carry out the rest of the example?

imtools.py gives error

By typing the below mentioned commands on command prompt by going into the folder of pca images e.g., C:\Users\Dell\Desktop\pcv_data\data> and typing the python on that prompt:
from PIL import Image
from numpy import *
im = array(Image.open(’AquaTermi_lowcontrast.jpg’).convert(’L’))
im2,cdf = imtools.histeq(im)

I see the following errors:

Traceback (most recent call last):
File "", line 1, in
NameError: name 'imtools' is not defined

I put the imtools.py file into the same folder in which I am calling 'AquaTermi_lowcontrast.jpg'.
Is there a way to deal with such error. I am following the book tutorial given in the "Programming Computer Vision with Python by Jan Erik Solem". The same problem with your tutorial has been posed on stackoverflow and mail.python.org but I tried to call it first using
from imtools import *
import runs successfully but when i parse ''imtools.histeq(im)'' it gives me the error which is already mentioned above. And I also want to know what is best way to put these module code into which folder from where we can easily call them when needed without giving any path again and again.
Thanks.

matching word-frequency with word-ID in Imagesearch.py

Hello, @jesolem
I'm truly thankful for PCV sources.
Recently, I found that there might be a problem of indexing in Imagesearch.py
I just want to confirm whether the original code is right.

if we look into querying function, we can notice query() -------> candidate_from_histogram() -------> candidates_from_word().

def candidates_from_word(self,imword):
      im_ids = self.con.execute( "select distinct imid from imwords where wordid=%d" % imword).fetchall()

Meanwhile, I think the value indexed to imword table is not word-id, but word-frequency.

def add_to_index(self, imname, descr):
      ...
      imwords = self.voc.project(descr)
      nbr_words = imwords.shape[0]

      # link each word to image
      for i in range(nbr_words):
          word = imwords[ i ]
          # wordid is the word number itself
          self.con.execute("insert into imwords(imid,wordid,vocname) values (?,?,?)",  (imid,word,self.voc.name))

So, it seems that word-id and word-frequency are compared. Isn't it wrong?
I think the add_to_index() should be fixed as comparison between word-id and word-id like below.

def add_to_index(self, imname, descr):
      ...
      imwords1 = self.voc.project(descr)
      imwords2 = imwords1.nonzero()[0]
      nbr_words = imwords2.shape[0]

      # link each word to image
      for i in range(nbr_words):
          word = imwords2[ i ]
          # wordid is the word number itself
          self.con.execute("insert into imwords(imid,wordid,vocname) values (?,?,?)",  (imid,word,self.voc.name))
          # store word histogram for image
          # use pickle to encode NumPy arrays as strings
          self.con.execute("insert into imhistograms(imid,histogram,vocname) values (?,?,?)", (imid,pickle.dumps(imwords1),self.voc.name))

[HELP Needed] OSError: filename.sift not found.

Hello,
I am working on image feature matching and I started following the code examples of the PCV book. the following code
`imname1 = './data/sample1.jpg'
imname2 = './data/sample2.jpg'

process and save features to file

sift.process_image(imname1, 'sample1.sift')
sift.process_image(imname2, 'sample2.sift')works fine and I get a message when done _" processed tmp.pgm to sample1.sift" "processed tmp.pgm to sample2.sift"_ but when I am trying to use thisl1, d1 = sift.read_features_from_file('sample1.sift')
l2, d2 = sift.read_features_from_file('sample2.sift')
matchscores = sift.match_twosided(d1, d2)`
I get an OSError that says sample.sift not found
Can you help me?

Harris corner detector

Your fix of Harris corner detector on Jan 23, 2013 would be wrong.
According to Noble 1989, the corner measure is not det/trace^2, but det/trace. The original source code is right and the quotient on P.30 is wrong.

Thank you for consideration in advance.

computer vision with python - sift example error

hello
i'm trying examples in programming computer vision with python.
when I try sift example in page 95, I have error as follow

Traceback (most recent call last):
File "C:\Users\admin\Desktop\tasdfasdfasfd\ch3_panorama.py", line 25, in
l[i],d[i] = sift.read_features_from_file(featname[i])
File "C:\Users\admin\Desktop\tasdfasdfasfd\sift.py", line 25, in read_features_from_file
f = loadtxt(filename)
File "C:\Python27\lib\site-packages\numpy\lib\npyio.py", line 896, in loadtxt
fh = iter(open(fname, 'U'))
IOError: [Errno 2] No such file or directory: 'Univ1.sift'

how can I solve this problem???

About wordid in image search module

def add_to_index(self,imname,descr):
""" Take an image with feature descriptors,
project on vocabulary and add to database. """
if self.is_indexed(imname): return print ’indexing’, imname

get the imid

imid = self.get_id(imname)

get the words

imwords = self.voc.project(descr)
nbr_words = imwords.shape[0]

link each word to image

for i in range(nbr_words):
word = imwords[i]

wordid is the word number itself self.con.execute("insert into imwords(imid,wordid,vocname)

      values (?,?,?)", (imid,word,self.voc.name))

store word histogram for image

use pickle to encode NumPy arrays as strings self.con.execute("insert into imhistograms(imid,histogram,vocname)

values (?,?,?)", (imid,pickle.dumps(imwords),self.voc.name))

For the following code:

wordid is the word number itself

self.con.execute("insert into imwords(imid,wordid,vocname)")

In the imwords table, we want to see for a given visual word, which of the images are related to the visual word, so we should insert the (imid,word index) if its word number is non-zero, why do we insert the word number itself? the word number can be the index for one word??

TypeError: a bytes-like object is required, not 'str'

Traceback (most recent call last):
File "imgsearch.py", line 32, in
res_reg = [w[1] for w in src.query(imlist[q_ind])[:nbr_results]] # 查询的结果
File "/opt/conda/lib/python3.8/site-packages/PCV/imagesearch/imagesearch.py", line 128, in query
h = self.get_imhistogram(imname)
File "/opt/conda/lib/python3.8/site-packages/PCV/imagesearch/imagesearch.py", line 96, in get_imhistogram
return pickle.loads(str(s[0]))
TypeError: a bytes-like object is required, not 'str'

env: python3.8.8

3d sfm example in chapter 5 is fairly broken in a subtle way

See commit nico/cvbook@102a8b0 – the arguments to F_from_ransac() need to be swapped.

You don't have this example in your repo, so no pull request. I tried this with the two alcatraz pics you're using in the book, and the error looks smaller with this change (http://i.imgur.com/3md1jMp.jpg) than without it (http://i.imgur.com/VhJQ5mM.jpg) there too.

(It's of course possible I got some other bit of my code wrong which happens to require this fix. I triple-checked that I didn't, but who knows. Maybe you can publish your code for the 3d reconstruction example in chapter 5, then I could check if it works with my input images without modifications.)

sift.py plot_matches error

function plot_matches in sift.py should contain:
plot([locs1[i][0],locs2[m][0]+cols1],[locs1[i][1],locs2[m][1]])

because in locs coordinate x comes before y

Can use graph cut to multi-label segment?

Hello, thanks of your contribution about such good work.
I am using graph neural network to parcel brain region, however the result is not good, I want to use graph cut as post process.
The inputs of my current model are: adjacency matrix (10242, 10242), feature matrix (10242, 6), label matrix (10242). The output is the probability y that each node belongs to a label, and its dimension is (10242, 36)
I want to use graph cut to update y for better performance.

I have a few questions about your code:
First, it seems that your code is only for two categories. Can you do multi label tasks?
Second, if I want to do post-processing, what should my input be?

Lack of several image files

Hi Jan Erik,

Thanks for your previous answer. I'm keep going on your textbook.
Please let me make another question.

I'm missing several image files in the folder 'data' which was extracted from pcv_data.zip. The files such as 'cat.jpg' and 'billboard_for_rent.jpg' seem not to be included in the zip file. In addition, I guess more several files are missing in that.

Could you show me the URL to download the image files?
Thanks.

Takeshi

Query return error

Hello, i got a problem while running ch7_searchdemo.py :

Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/cherrypy/_cprequest.py", line 670, in respond
response.body = self.handler()
File "/Library/Python/2.7/site-packages/cherrypy/lib/encoding.py", line 221, in call
self.body = self.oldhandler(*args, **kwargs)
File "/Library/Python/2.7/site-packages/cherrypy/_cpdispatch.py", line 60, in call
return self.callable(*self.args, *self.kwargs)
File "demo.py", line 53, in index
res = self.src.query(query)[:self.maxres]
File "/Applications/Recherche/PCV-master/build/lib/PCV/imagesearch/imagesearch.py", line 136, in query
cand_dist = sqrt( sum( self.voc.idf
(h-cand_h)**2 ) )
ValueError: operands could not be broadcast together with shapes (993,) (991,)

I know that mean the "h" and the cand_h histogram can't be subtracted but i know why ?

(i am using the ukbench dataset)

possible error in camera.py

to factorize the camera matrix P
line 26 to line 41

def factor(self):
    """    Factorize the camera matrix into K,R,t as P = K[R|t]. """

    # factor first 3*3 part
    K,R = linalg.rq(self.P[:,:3])

    # make diagonal of K positive
    T = diag(sign(diag(K)))
    if linalg.det(T) < 0:
        T[1,1] *= -1

    self.K = dot(K,T)
    self.R = dot(T,R) # T is its own inverse
    self.t = dot(linalg.inv(self.K),self.P[:,3])

    return self.K, self.R, self.t

base on the example in the book on page 108

import camera
K = array([[1000,0,500],[0,1000,300],[0,0,1]])
tmp = camera.rotation_matrix([0,0,1])[:3,:3]
Rt = hstack((tmp,array([[50],[40],[30]])))
cam = camera.Camera(dot(K,Rt))
print K,Rt
print cam.factor()

K,R = linalg.rq(self.P[:,:3]) returns
K = [[ 1000., 0., 500.],
[ 0., -1000., 300.],
[ 0., 0., 1.]]
T = diag(sign(diag(K))) returns
T = [1, -1, 1]
linalg.det(T) returns -1.0
then T[1,1] *= -1 will not make diagonal of K positive

Run SnapSudoku on a smart phone?

prajwalkr/SnapSudoku#3

It would be cool to get SnapSudoku running on the iPhone so that you could use the camera to do the snap and immediately solve the puzzle right on the phone. It would drive Sudoku players crazy if you could walk up with your smart phone, snap a picture of their puzzle, and show them the solution. Pythonista is a Python 2.7 and 3.5 IDE for iOS. Pythonista does support NumPy, Matplotlib, and Pillow (PIL) but does not yet support OpenCV or SciPy.

@jesolem @nico @The-Penultimate-Defenestrator

Chpter 5: Multiple view geometry code?

Hi Jan-

Any chance you could post the code from chapter 5? I wanted to mess around with the plane_sweep stuff (stereo.py) and right now it looks like that would require typing in the code manually from the book?

-darkgreen

ImportError: No module named PIL

I'm not familiar with python, when I run the sample, it say:
Traceback (most recent call last):
File "/Users/leocone/Study/PCV/examples/ch1_morphology.py", line 1, in
from PIL import Image
ImportError: No module named PIL

No code for chapter 8 in examples!

disappointing. any reason for not including the code? should i type now everything from the book pages? or is it an educational concept?

Problem to use sift in Vlfeat

Hi, jesolem. In the sift.py:

    cmmd = str("sift.exe "+imagename+" --output="+resultname+
                " "+params)
    os.system(cmmd)

I have read you blog post Another Python Interface for SIFT. You use the os.system() to call the vlfeat's sift.exe in the context the environment variable has been added to the system path. I did so, but it failed to dectect the sift key points.

Instead, I change it with a full path:

    cmmd = str("D:\\mltools\\vlfeat\\sift.exe "+imagename+" --output="+resultname+
                " "+params)

then it succeeds.

I don't know the reason why the former failed, can you help to let the former succeed?

PCV search image problem in imagesearch.py

since the python 2.7.x contains the sqlite and the version is sqlite3. The imagesearch.py in the PCV:

from pysqlite2 import dbapi2 as sqlite

should be corrected as follows:

from sqlite3 import dbapi2 as sqlite

Then you will succeed.

Where can we find image files?

Dear Jan Erik Solem,

Many thanks for your book, "Programming Computer Vision with Python."
I'm learning how to process computer images by your book.

Although there are many image files used in the sample programs, I could not find them in this repository. Some files have path like 'data/image.png', but I could not find such folder.

We can find several reference sites for us to collect image files in your book. But do we have to pick up each image file to trace your sample codes?

I'll be happy if I could have a good way to gather the image files.
Thanks.

Best,
Takeshi Akutsu (@akucchan_world)

Small bug in sift.py of PCV-note

Hi Jan Erik,

I found a small bug in the code of PCV/pcv_book/sift.py.
https://github.com/jesolem/PCV/blob/master/pcv_book/sift.py

In the line 112, it is written like below,

plot([locs1[i][1],locs2[m][1]+cols1],[locs1[i][0],locs2[m][0]],'c')

This line is different from the code of PCV/PCV/localdescriptors/sift.py.
https://github.com/jesolem/PCV/blob/master/PCV/localdescriptors/sift.py

plot([locs1[i][0],locs2[m][0]+cols1],[locs1[i][1],locs2[m][1]],'c')

As you can see, X-Y coordinates are written differently between the two files, and the latter is correct. Since I used the first one in my practice, I've been stuck on drawing the corresponding lines.

I would be happy if this message helps you.

Best,
Takeshi

IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

File "gen_vocabulary.py", line 24, in
voc.train(featlist, 122, 10)
File "/opt/conda/lib/python3.8/site-packages/PCV/imagesearch/vocabulary.py", line 24, in train
descr.append(sift.read_features_from_file(featurefiles[0])[1])
File "/opt/conda/lib/python3.8/site-packages/PCV/localdescriptors/sift.py", line 26, in read_features_from_file
return f[:,:4],f[:,4:] # feature locations, descriptors
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

Graphcut example not working

Dear Erik,
I have been learning about graph cuts and found probably a mistake in your book. At page 244 in chapter 9 in your final drafted book, you have different pictures than me after I have run your code.
I imported graphcut.py, in which the bayes.py is also included. I had run the code from Page 243. But the pictures what I see is not as yours in your book
I don't know what can be a problem. I have already saved the pictures what I got from my run, so if you are interested I can send you.

Python 3 compatibility?

I have installed PCV on Anaconda with python 3.5 and tried to compile this:

from PIL import Image
from pylab import *
from numpy import *

from PCV.localdescriptors import dsift, sift

basically dense sift example in examples. The compiler gives me the output:

Traceback (most recent call last):
File "C:\Dropbox\Python\Sorusana\main.py", line 9, in
from PCV.localdescriptors import dsift, sift
File "C:\Anaconda3\lib\site-packages\PCV\localdescriptors\dsift.py", line 38
print 'processed', imagename, 'to', resultname
^
SyntaxError: Missing parentheses in call to 'print'
[Finished in 1.5s]

I think it's because python 2 neture of the library. Any solutions?

sift --edge-thresh 10 Error: unknown flag `edge-thresh'

Hello,

I downloaded shift and while executing (this is in reference to book "programming computer Vision with python" by author Jan Erik Solem)

what I need to do to resolve this...?

-Thanks
-Alok

python examples/ch3_panorama.py
Error: unknown flag `edge-thresh'
processed tmp.pgm to ../data/Univ1.sift
Traceback (most recent call last):
File "examples/ch3_panorama.py", line 24, in
l[i],d[i] = sift.read_features_from_file(featname[i])
File "/Users/akmishra/Development/python2.7/lib/python2.7/site-packages/PCV/localdescriptors/sift.py", line 25, in read_features_from_file
f = loadtxt(filename)
File "/Users/akmishra/Development/python2.7/lib/python2.7/site-packages/numpy/lib/npyio.py", line 962, in loadtxt
fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
File "/Users/akmishra/Development/python2.7/lib/python2.7/site-packages/numpy/lib/_datasource.py", line 266, in open
return ds.open(path, mode, encoding=encoding, newline=newline)
File "/Users/akmishra/Development/python2.7/lib/python2.7/site-packages/numpy/lib/_datasource.py", line 624, in open
raise IOError("%s not found." % path)
IOError: ../data/Univ1.sift not found.

Excited to see you get down to the second edition of PCV

Hi, jesolem. In your examples2 I'm very glad to see this:

This folder contains work in progress and files intended for the second edition of "Programming Computer Vision with Python".

I'm excited to see you get down to the second edition of Programming Computer Vision with Python.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.