Ask Your Question
1

OpenCV RNG and seeding

asked 2016-12-02 17:13:47 -0600

phillity gravatar image

Hi everyone

I am trying to convert these lines of Matlab code to Java using OpenCV 3.1:

for i=1:1:height // height = 196
   rng(signatureShift(i)); // 196x1 Mat containing int values from 0 to 10
   keySequence(i,:)=rand(1,width); // generates double values between 0 and 1
   keySequence(i,:)=round(keySequence(i,:)); // rounds the generated double values

Can someone give me some pointers on how to accomplish this using the OpenCV library?

edit retag flag offensive close merge delete

Comments

I see I should probably use RNG rng(signatureShift(i)) to seed. What imports do I need in Java OpenCV 3.1 for the RNG class, because I can't seem to find it :(

phillity gravatar imagephillity ( 2016-12-02 17:35:48 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-12-03 00:32:46 -0600

berak gravatar image

updated 2016-12-03 01:29:56 -0600

unfortunately opencv's java bindings do not have a RNG class.

you can use randn() , randu(), randShuffle(), etc

(which are all using the global cv::theRNG() under the hood),

but there will be no way of actually seeding it (default seed is 0xffffffff)

you'll probably have to use java's own Random class here instead.

edit flag offensive delete link more

Comments

Thanks, that's what I ended up doing

phillity gravatar imagephillity ( 2016-12-03 17:04:01 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-12-02 17:13:47 -0600

Seen: 759 times

Last updated: Dec 03 '16