En C++/opencv, comment puis-je sélectionner un sous-ensemble d'un gros Mat et les copier pour créer un nouveau Mat? Je sais comment utiliser copyto, colrange, rowrange, etc., mais je ne sais pas les combiner pour développer un code décent et efficace. Merci!Sélectionnez un sous-ensemble d'un Mat et copiez-les pour créer un nouveau mat dans C++/Opencv
2
A
Répondre
5
Vous pouvez utiliser copyTo() à cet effet:
//copy a sub matrix of X to Y with starting coodinate (startX,startY)
// and dimension (cols,rows)
cv::Mat tmp = X(cv::Rect(startX,startY,cols,rows));
cv::Mat Y;
tmp.copyTo(Y);
ou directement:
cv::Mat Y;
X(cv::Rect(startX,startY,cols,rows)).copyTo(Y);
+0
Devrait être 'tmp' au lieu de' temp'. –
Questions connexes
- 1. Créer un mat plus efficace pour chromakey?
- 2. OpenCV mat * image = (Mat *) image
- 3. Fichiers gmdistribution.fit et .mat
- 4. OpenCV Mat à JavaCV Mat conversion
- 5. différence entre cv :: Mat aaa(); et cv :: Mat aaa = cv :: Mat();
- 6. comment créer un fichier .mat avec l'horodatage actuel dans matlab?
- 7. Itère Mat
- 8. Convertir uchar Mat en float Mat dans OpenCV?
- 9. Double pointeur d'initialisation Mat
- 10. créer un fichier .mat à partir de python
- 11. Mat et la fonction setMouseCallback
- 12. Comment créer un fichier .mat pour stocker plusieurs images et ses histogrammes.
- 13. Définir cv :: Mat dans l'en-tête suivi par un autre Mat évite plusieurs canaux
- 14. Combinaison de deux fichiers .mat en un
- 15. Bitmap dans Android et Mat dans OpenCV
- 16. Comment convertir un IplImage * en cv: Mat *?
- 17. Comment faire pour convertir mat à bitmap et bitmap à mat?
- 18. Mauvaise adresse dans cv :: Mat
- 19. Charger l'image dans Mat existant
- 20. Opencv push_back fonction dans Mat
- 21. Convertir Mat en QPixmap
- 22. cv ::: Mat clone Segfault
- 23. Structure de Mat dans opencv?
- 24. Fusionner plusieurs cv :: Mat?
- 25. Multiplication des types Mat et Vec_
- 26. Convertir Mat en ** float
- 27. Mat monocanal Element accès
- 28. Comparer 2 cv :: Mat
- 29. Convertir Bitmap en Mat, FAIL
- 30. Charger un fichier .mat dans un autre fichier sans accéder au nom de la variable du fichier .mat
Jetez un oeil à (http://docs.opencv.org [Mat :: clone()] /modules/core/doc/basic_structures.html#mat-clone) – user2510575