Maruthi Krishna has Published 951 Articles

How to draw a filled circle in OpenCV using Java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:48:35

465 Views

The org.opencv.imgproc package of Java OpenCV library contains a class named Imgproc. This class provides a method named circle(), using this you can draw a circle on an image. This method provides the following parameters −A Mat object representing the image on which the circle is to be drawn.A Point ... Read More

How to convert OpenCV Mat object to JavaFX WritableImage?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:46:37

256 Views

If you try to read an image using the OpenCV imread() method it returns a Mat object. If you want to display the contents of the resultant Mat object using a JavaFX window You need to convert the Mat object to an object of the class javafx.scene.image.WritableImage. To do so, ... Read More

How to draw geometrical shapes on image using OpenCV Java Library?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:44:11

381 Views

The org.opencv.imgproc package of Java OpenCV library contains a class named Imgproc this class provies various methods such as, resize(), wrapAffine(), filter2D, to process an input image.In addition to them It provides a set of method to draw geometrical shapes on images, Following are some of them −ShapeMethod and DescriptionEllipseYou ... Read More

How to Update multiple documents in a MongoDB collection using Java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:38:53

1K+ Views

Using the updateMany() method you can update all the documents of a collection.Syntaxdb.COLLECTION_NAME.update(, )In Java the com.mongodb.client.MongoCollection interface provides you a method with the same name. Using this method you can update multiple documents in a collection at once, to this method you need to pass the filter and values ... Read More

How to update an existing document in MongoDB collection using Java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:36:22

3K+ Views

The update() method updates the values in the existing document.Syntaxdb.COLLECTION_NAME.update(SELECTIOIN_CRITERIA, UPDATED_DATA)In Java, you can update a single document using the updateOne()method of the com.mongodb.client.MongoCollection interface. To this method, you need to pass the filter and values for the update.Exampleimport com.mongodb.client.FindIterable; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; import com.mongodb.client.model.Filters; import com.mongodb.client.model.Updates; import java.util.ArrayList; ... Read More

How to sort the documents of a MongoDB collection using java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:34:15

1K+ Views

While retrieving records from a MongoDB collection, you can sort the records in the result using the sort() method.Syntaxdb.COLLECTION_NAME.find().sort({KEY:1})The Java MongoDB library provides a method with the same name, to limit the number of records invoke this method (on the result of the find() method) by passing the type of ... Read More

How to create a database in MongoDB using Java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:32:09

1K+ Views

There is no separate method to create a MongoDB database in Java, you can create a database by invoking the getDatabase() method of the com.mongodb.MongoClient class.Exampleimport com.mongodb.MongoClient; public class CreatingDatabase {    public static void main( String args[] ) {       //Creating a MongoDB client       ... Read More

How to create an index in MongoDB using Java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:30:52

2K+ Views

In MongoDB to create an index, you need to use createIndex() method.Syntaxdb.COLLECTION_NAME.createIndex({KEY:1})Where the key is the name of the file on which you want to create index and 1 is for ascending order. To create an index in descending order you need to use -1.In Java, you can create an ... Read More

How to delete multiple documents from a collection using Java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:28:59

805 Views

In Java the com.mongodb.client.MongoCollection interface provides a method deleteMany(). Using this method you can delete multiple documents from a collection at once, to this method you need to pass the filter specifying the deletion criteria.Exampleimport com.mongodb.client.FindIterable; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.bson.Document; import org.bson.conversions.Bson; ... Read More

How to drop a database in MongoDB using java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:25:59

548 Views

MongoDB db.dropDatabase() command is used to drop a existing database.This will delete the current database. if you haven't selected any, the default (test) database will be deleted.Syntaxdb.dropDatabase()In Java to delete a database, first of all, get the object of the required database using the getDatabase() method and delete it by ... Read More

Advertisements