Ask Your Question

U.Swap's profile - activity

2020-09-12 09:46:24 -0600 received badge  Notable Question (source)
2018-12-18 06:54:04 -0600 received badge  Popular Question (source)
2017-12-28 07:10:39 -0600 asked a question opencv python process(segmentise) non-rectangular region without masking

opencv python process(segmentise) non-rectangular region without masking I have extracted the co-ordinates of the non-re

2017-12-28 07:09:54 -0600 commented question Opencv map predefined GT cordinates to different aspect ratio

they are list of tuples with x,y co-ordinates

2017-12-27 03:26:50 -0600 edited question Opencv map predefined GT cordinates to different aspect ratio

Opencv map predefined GT cordinates to different aspect ratio I have a dataset of eye gluacoma with predefined ground tr

2017-12-27 03:17:56 -0600 edited question Opencv map predefined GT cordinates to different aspect ratio

Opencv map predefined GT cordinates to different aspect ratio I have a dataset of eye gluacoma with predefined ground tr

2017-12-27 03:17:05 -0600 asked a question Opencv map predefined GT cordinates to different aspect ratio

Opencv map predefined GT cordinates to different aspect ratio I have a dataset of eye gluacoma with predefined groud tru

2017-12-03 09:25:41 -0600 asked a question opencv detect image is tempored/photoshoped

opencv detect image is tempored/photoshoped I have came across problem where i need to detect whether given image is man

2017-07-06 03:53:41 -0600 commented answer python opencv sliding window issue

Thanks for your answer, but i have just edited my rolling_window fun. just see my question, but it throws me exception when I get 3D color histogram of that. the exception is: "Assertion failed (j < nimages) in histPrepareImages" , I have added the 3D histogram func. in my question pls see that as well.

2017-07-05 04:12:45 -0600 asked a question python opencv sliding window issue

Am making use of sliding/rolling window technique to devide the input image into equal chunks of given size so for that am making use of following function to devide image into specified window size.

[Edited below fun. defination]

def rolling_window(base_cord,test_image, window):
    """Very basic multi dimensional rolling window. window should be the shape of
    of the desired subarrays. Window is either a scalar or a tuple of same size
    as `arr.shape`.
    """
    rest_c_ls = []
    windowsize_r = window[0]
    windowsize_c = window[1]
    chunk_arr = {}

    for r in range(0, test_image.shape[0] - windowsize_r, windowsize_r):
        for c in range(0, test_image.shape[1] - windowsize_c, windowsize_c):
            win = test_image[r:r + windowsize_r, c:c + windowsize_c]
            cord = (r+base_cord[0], c+base_cord[1])
            rest_c_ls.append(cord[1])
            chunk_arr[cord] = win
        else:
            rest_c = (test_image.shape[1] - windowsize_c)
            rest_c_ls.append(rest_c)
            win = test_image[r:r + windowsize_r, rest_c:rest_c + windowsize_c]
            cord = (r + base_cord[0], rest_c + base_cord[1])
            chunk_arr[cord] = win
            #print test_image.shape[1] - windowsize_c
    else:
        for rest_c in rest_c_ls:
            rest_r = (test_image.shape[0] - windowsize_r)
            win = test_image[rest_r:rest_r + windowsize_r, rest_c:rest_c + windowsize_c]
            cord = (rest_r + base_cord[0], rest_c + base_cord[1])
            chunk_arr[cord] = win

            #print 'else'+str(test_image.shape[0] - windowsize_r)
        #test_image[r:r + windowsize_r, c:c + windowsize_c]

    return chunk_arr

So, this function returns me the window of specified size lets say 50x50 along with its base cordinates in dictionary format.

But problem is suppose I pass down the image of any odd size like 968x885 then spliting equal size chunks of size 50x50 will left some odd boundary pixels at the end of the image , the resuling image after first round of sliding window looks something like below.

enter image description here

As we can see above , the pixels at right side are not chunked into window coz it's < 50x50 window size.

So what i want is to modify rolling_window function in order to form seperate window chunk for remaining pixels in every possible row/column. So how to achieve this.

Also, I have updated this question as have a function to calculate 3D histogram for given image window , so after updating the above window function I am able to get all the remaining chunks of the windows but it thows me exception while calculating the 3D histogram, here function.

def extract_color_histogram(image, bins=(8, 8, 8)):
    # extract a 3D color histogram from the HSV color space using
    # the supplied number of `bins` per channel
    hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)

    hist = cv2.calcHist([hsv], [0, 1, 2], None, bins,
                        [0, 180, 0, 256, 0, 256])

    # handle normalizing the histogram if we are using OpenCV 2.4.X
    if imutils.is_cv2():
        hist = cv2.normalize(hist)

    # otherwise, perform "in place" normalization in OpenCV 3 (I
    # personally hate the way this is done
    else:
        cv2.normalize(hist, hist)

    # return the flattened histogram as the feature vector
    return hist.flatten()
    #except Exception as e:
    #    print e

Now it's throwing exception at this line :

hist = cv2.calcHist([hsv], [0, 1, 2], None, bins,
                            [0, 180, 0, 256, 0, 256])

OpenCV Error: Assertion failed (j < nimages ...

(more)
2017-05-22 07:03:40 -0600 asked a question opencv python merge different channel images into one

I have few satellite images each of them represents one channel of main satellite image, these are 11 images in total, each are labled with different channel, all images are in .tiff format with grayscale colorspace, now i simply want's to merge these images into one, to represent all channels into one image, so is this possible, remeber here, I don't want to concat images , which can be done using this:

vis = np.concatenate((img1, img2), axis=1)

I want to merge all of them into one single image , without distorting the data contained within, few channel images are attached below.

enter image description here enter image description here enter image description here enter image description here

Any help is appreciated.

2017-05-17 11:24:09 -0600 asked a question sattelite image classification Opencv python

Am trying to classify different terrains/regions from the given satellite image which is in grayscale , 2 band spectrums.. By far i have computed the average pixel intensities of the pixels in the respective terrains. and randomly selected some pixels from specific regions , and now am looking to train these group of pixels using SVM possibly using LinearSVM, so what would be the appropriate approach to classify different terrains in the image, any algorithmic steps are much appreciated and that exactly what am looking for, steps to achieve this. BTW am using python with OpenCV for this.

enter image description here

This is the gray scale image that i willing to classify..

enter image description here

And this is what am expecting after classifying different terrains , by simply coloring different regions to highlight them, every color in the colored image signify highlighted region like blue colored region represents sea/river , the color in red represents forest region , also the rest of terrain in white color represents urbanized area in the city.

Any help is appreciated!

2017-02-04 02:40:44 -0600 received badge  Scholar (source)
2017-02-04 02:40:42 -0600 commented answer latentsvm detector in Python

OK, that's dissapointing!

2017-02-04 02:15:19 -0600 asked a question latentsvm detector in Python

I found several latentsvm classifiers from some source , but I don't know how to test it using Python source, am familier with using haar-classifiers in opencv with python, but is there any way for using latentsvm classifiers with python the way we use for haar-classifiers coz, I have already googled enough for this, but haven;t found any source which makes it possible in python, so any genius here who has utilized latenentsvm in python opencv. any help will be greatly appreciated.

2017-01-13 04:44:27 -0600 commented answer Detect fire/flame using HSV filter to contours.

how about training HOG+SVM in order to detect flames, using sliding window?

2017-01-12 08:40:08 -0600 asked a question Detect fire/flame using HSV filter to contours.

I want to detect fires/flames, in realtime camera stream, is it possible to do this using HSV color space and apply mask and filters to appropriately detect contours in given HSV colorspace, so what could be the HSV range that can identify/detect fire/flames.

2017-01-09 03:03:13 -0600 commented question Get ROI from face landmark points cv2 dlib

Thanks, thats what I was looking for.

2017-01-08 05:37:27 -0600 commented question Get ROI from face landmark points cv2 dlib

that's the one, thanx. but can you just tell me how can i associate boundingRect, before

cv2.imwrite("my.png", img[minY:maxY, minX:maxX])
2017-01-08 05:05:51 -0600 commented question Get ROI from face landmark points cv2 dlib

sorry for misleading terms, but can you propose some effective solution for this.

2017-01-08 04:24:13 -0600 asked a question Get ROI from face landmark points cv2 dlib

Am using following code to draw facial landmark points using dlib , on to the frames captured from webcam in realtime, now what am looking for is to get the ROI that bounds all the points complying the face , the code is as follows:

import cv2
import dlib
import numpy
from imutils.video import FPS
from imutils.video import WebcamVideoStream
import imutils

PREDICTOR_PATH = "./shape_predictor_68_face_landmarks.dat"
predictor = dlib.shape_predictor(PREDICTOR_PATH)
cascade_path = 'cascade/haarcascade_frontalface_default.xml'
cascade = cv2.CascadeClassifier(cascade_path)

webcam = WebcamVideoStream(src=0).start()
fps = FPS().start()

while True:
    im = webcam.read()
    im = imutils.resize(im, width=400)

    faces = cascade.detectMultiScale(im, 1.3, 5)
    if len(faces) != 0:
        for (x, y, w, h) in faces.astype(long):
            rect = dlib.rectangle(x, y, x + w, y + h)
            #cv2.imwrite('face.png', rect)
            get_landmarks = numpy.matrix([[p.x, p.y] for p in predictor(im, rect).parts()])

        for idx, point in enumerate(get_landmarks):
            pos = (point[0, 0], point[0, 1])
            cv2.putText(im, str(idx), pos,
                        fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX,
                        fontScale=0.4,
                        color=(0, 0, 255))
           # cv2.drawContours(im, [pos], -1, (0, 255, 0), 2)
#            hullIndex = cv2.convexHull(pos, returnPoints=False)
#            cv2.imwrite('face.png', hullIndex)
            cv2.circle(im, pos, 3, color=(0, 255, 255))
    cv2.imshow('Result', im)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
    fps.update()

cv2.destroyAllWindows()

I want to dump the facial landmark points into image file. but am unable to understand , how I can extract ROI from these landmark points and then dump to file using

cv2.imwrite('face.png', hullIndex)

, but here I don't want the rectangle drwaned using

faces = cascade.detectMultiScale(im, 1.3, 5)

, I want only the shape that circumfencec the facial landmark points, the output of the above code looks like below.

enter image description here

So, just dump only points that circumferences the facial edge points.

One proposed solution for this is given below, but it's also not working. Infact a confusing for me, a bit elaboration for this might help me understand it!

After getting the 68 facial landmarks from the predictor, You may simply iterate over all the points and update the minX, minY, maxX, maxY which after the iteration would yield the bounding rect exactly enclosing all the facial landmarks.

You may also use cv2.boundingRect(points) but you need to transform all the points to a numpy array before passing to this method.

But I would recommend you the first solution and it is fairly easy to implement as

minX, minY = 10000000, 10000000
maxX, maxY = 0, 0
for point in get_landmarks:
    if point[0] < minX:
        minX = point[0]
    elif point[0] > maxX:
        maxX = point[0]
    elif point[1] < minY:
        minY = point[1]
    elif point[1] > maxY:
        maxY = point[1]

bounding_rect = [minX, minY, maxX - minX, maxY - minY]
2017-01-01 00:11:01 -0600 received badge  Enthusiast
2016-12-26 09:27:46 -0600 received badge  Critic (source)
2016-10-27 09:41:56 -0600 received badge  Supporter (source)