Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Does saliency module from opencv_contrib work in python ?

Hi,

I am trying the Motion saliency algorithm in the Saliency module from Opencv_contrib (in python) but it doesn't seem to work. I didn't find any example on how to use the python wrapping of these functions. Did anyone try it before and can help me figure out what's wrong ?

Thank you

Does saliency module from opencv_contrib work in python ?

Hi,

I am trying the Motion saliency algorithm in the Saliency module from Opencv_contrib (in python) but it doesn't seem to work. I didn't find any example on how to use the python wrapping of these functions. Did anyone try it before and can help me figure out what's wrong ?

Thank you

EDIT!: output of help(cv2.saliency)

Help on module cv2.saliency in cv2:

NAME
    cv2.saliency

FILE
    (built-in)

FUNCTIONS
    MotionSaliencyBinWangApr2014_create(...)
        MotionSaliencyBinWangApr2014_create()
-> retval

    ObjectnessBING_create(...)
        ObjectnessBING_create() -> retval

    StaticSaliencyFineGrained_create(...)
        StaticSaliencyFineGrained_create() -> retval

    StaticSaliencySpectralResidual_create(...)
        StaticSaliencySpectralResidual_create()
-> retval

Does saliency module from opencv_contrib work in python ?

Hi,

I am trying the Motion saliency algorithm in the Saliency module from Opencv_contrib (in python) but it doesn't seem to work. I didn't find any example on how to use the python wrapping of these functions. Did anyone try it before and can help me figure out what's wrong ?

Thank you

EDIT!:

The code I tried:

import cv2
import skvideo.io

video = skvideo.io.VideoCapture(video_file)
_, img = video.read()
imgsize = img.shape
saliency = cv2.saliency.MotionSaliencyBinWangApr2014_create()
saliency.setImagesize(imgsize[0], imgsize[1])
saliency.init()

while True:
    success, img = video.read()
    if success:
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        out = saliency.computeSaliency(gray)
        cv2.imshow("sal", out[1]*255)
     else:
          break

output of help(cv2.saliency)

Help on module cv2.saliency in cv2:

NAME
    cv2.saliency

FILE
    (built-in)

FUNCTIONS
    MotionSaliencyBinWangApr2014_create(...)
        MotionSaliencyBinWangApr2014_create()
-> retval

    ObjectnessBING_create(...)
        ObjectnessBING_create() -> retval

    StaticSaliencyFineGrained_create(...)
        StaticSaliencyFineGrained_create() -> retval

    StaticSaliencySpectralResidual_create(...)
        StaticSaliencySpectralResidual_create()
-> retval

Does saliency module from opencv_contrib work in python ?

Hi,

I am trying the Motion saliency algorithm in the Saliency module from Opencv_contrib (in python) but it doesn't seem to work. I didn't find any example on how to use the python wrapping of these functions. Did anyone try it before and can help me figure out what's wrong ?

Thank you EDIT!:

The code I tried:

import cv2
import skvideo.io

video = skvideo.io.VideoCapture(video_file)
_, img = video.read()
imgsize = img.shape
saliency = cv2.saliency.MotionSaliencyBinWangApr2014_create()
saliency.setImagesize(imgsize[0], imgsize[1])
saliency.init()

while True:
    success, img = video.read()
    if success:
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        out = saliency.computeSaliency(gray)
        cv2.imshow("sal", out[1]*255)
     else:
          break

The output is a white image

output of help(cv2.saliency)

Help on module cv2.saliency in cv2:

NAME
    cv2.saliency

FILE
    (built-in)

FUNCTIONS
    MotionSaliencyBinWangApr2014_create(...)
        MotionSaliencyBinWangApr2014_create()
-> retval

    ObjectnessBING_create(...)
        ObjectnessBING_create() -> retval

    StaticSaliencyFineGrained_create(...)
        StaticSaliencyFineGrained_create() -> retval

    StaticSaliencySpectralResidual_create(...)
        StaticSaliencySpectralResidual_create()
-> retval

[solved] Does saliency module from opencv_contrib work in python ?

Hi,

I am trying the Motion saliency algorithm in the Saliency module from Opencv_contrib (in python) but it doesn't seem to work. I didn't find any example on how to use the python wrapping of these functions. Did anyone try it before and can help me figure out what's wrong ?

Thank you EDIT!:

The code I tried:

import cv2
import skvideo.io

video = skvideo.io.VideoCapture(video_file)
_, img = video.read()
imgsize = img.shape
saliency = cv2.saliency.MotionSaliencyBinWangApr2014_create()
saliency.setImagesize(imgsize[0], imgsize[1])
saliency.init()

while True:
    success, img = video.read()
    if success:
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        out = saliency.computeSaliency(gray)
        cv2.imshow("sal", out[1]*255)
     else:
          break

The output is a white image

output of help(cv2.saliency)

Help on module cv2.saliency in cv2:

NAME
    cv2.saliency

FILE
    (built-in)

FUNCTIONS
    MotionSaliencyBinWangApr2014_create(...)
        MotionSaliencyBinWangApr2014_create()
-> retval

    ObjectnessBING_create(...)
        ObjectnessBING_create() -> retval

    StaticSaliencyFineGrained_create(...)
        StaticSaliencyFineGrained_create() -> retval

    StaticSaliencySpectralResidual_create(...)
        StaticSaliencySpectralResidual_create()
-> retval