Maruthi Krishna has Published 951 Articles

How to drop an index in MongoDB using Java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:24:24

462 Views

In MongoDB to drop an index, you need to use dropIndex() method.Syntaxdb.COLLECTION_NAME.dropIndex({KEY:1})In Java, you can drop an Index using the dropIndex() method, to this method you need to pass the type of the index (ascending or descending) and the field name on which you have created it.dropIndex(Indexes.ascending("name"));Exampleimport com.mongodb.client.MongoCollection; import com.mongodb.client.MongoDatabase; ... Read More

How to limit the number of records, while retrieving data from a MongoDB collection using Java?

Maruthi Krishna

Maruthi Krishna

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

531 Views

While retrieving records from a MongoDB collection, you can limit the number of records in the result using thelimit() method.Syntaxdb.COLLECTION_NAME.find().limit(no.of records needed)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 ... Read More

How to get the list of all the MongoDB databases using java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:18:10

844 Views

In MongoDB, you can view the list of databases using the show dbs command> show dbs admin config local myDatabase sampleDatabase students test testDBIn Java, you can get the list of all the databases in MongoDb using the getDatabaseNames() method.Exampleimport com.mongodb.client.MongoIterable; import com.mongodb.MongoClient; public class ListOfDatabases {    public static ... Read More

Explain Java MongoDB projections

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:16:54

1K+ Views

While retrieving data from MongoDb collections you can select only necessary data using projections. In Java, you can project necessary data while reading the documents from a collection using the projection() method. Invoke this method on the result of find(), bypassing the names of the required filed names as −projection(Projections.include("name", ... Read More

How to skip documents while retrieving data from MongoDB, using java?

Maruthi Krishna

Maruthi Krishna

Updated on 10-Apr-2020 07:14:51

215 Views

While retrieving records from a MongoDB collection, you can skip records in the result using the skip() method.Syntaxdb.COLLECTION_NAME.find().limit(NUMBER).skip(NUMBER)The Java MongoDB library provides a method with the same name, to skip records, invoke this method (on the result of the find() method) bypassing an integer value representing the number of records ... Read More

How to display OpenCV Mat object using Swings?

Maruthi Krishna

Maruthi Krishna

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

412 Views

The class ImageIcon is an implementation of the Icon interface that paints Icons from Images. You can display images on a Swing window using this class, the constructor of this class accepts a BufferedImage object as a parameter.Therefore to display an OpenCV image that is stored in a Mat object ... Read More

How to display OpenCV Mat object using JavaFX?

Maruthi Krishna

Maruthi Krishna

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

337 Views

The JavaFX library provides a class with name ImageView using this you can display an image. This class accepts an object of the WritableImage class.To display an image Stored in OpenCV Mat object you need to convert it into a WritableImage object and pass it the ImageView class.Exampleimport java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; ... Read More

How to convert a positive image to Negative to using OpenCV library?

Maruthi Krishna

Maruthi Krishna

Updated on 09-Apr-2020 13:59:35

252 Views

Algorithm to convert an image to negativeGet the red green blue values of each pixelSubtract each color value from 255 and save them as new color values.Create a new pixel value from the modified colors.set the new value to the pixel.Implementation in JavaRead the required image using ImageIO.read() method.Get the ... Read More

How to declare OpenCV Mat object using Java?

Maruthi Krishna

Maruthi Krishna

Updated on 09-Apr-2020 09:24:23

549 Views

In OpenCV Mat class represents a matrix object which is used to store images. You can also declare a Mat object manually −Load the OpenCV native library − While writing Java code using OpenCV library, the first step you need to do is to load the native library of OpenCV ... Read More

Explain the Mat class in Java OpenCV library

Maruthi Krishna

Maruthi Krishna

Updated on 09-Apr-2020 09:22:09

2K+ Views

In OpenCV, images are stored in Using Mat object. It is nothing but an n-dimensional array and is used to store image data of grayscale or color images, voxel volumes, vector fields, point clouds, tensors, histograms, etc.If you try to read an image using the OpenCV library it will be ... Read More

Advertisements