2013-09-26 07:13:11 -0600 | commented question | App Crashes when I try to get RGB values from cv::Mat huraahhhh.... I just figured it out :D @Moster thanx alot.... your comment put me on the right track :) Some how my camera was stoping after sending 24 frames, and the last 6 indexes in my array contained garbage data(I assume). So when the code tried to get the RGB value of 25th frame, it crashed. The number of channels of last 6 Mats were also 1(it should be 4 as it s BGRA type) ,so checking this also hinted me towards right direction. The Crashing problem is solved now and m moving ahead. Thanx alot again :) |
2013-09-26 05:37:02 -0600 | commented question | App Crashes when I try to get RGB values from cv::Mat @Moster: Thanks for the response. I just tried the img.type() and come to know a different thing. Actually here is what I am attempting: Saving 30 frames(cv::Mat) from the video using the delegate method of CvVideoCamera. Then trying to apply an algorithm on RGB values of each frame. Now when I tried img.type() I came to know that it is not crashing for the first frame. It works fine for the first 24 frames, giving me img.type() = 24 in the console, and then for the 25th frame, it prints img.type() = 0. This is where its crashing. |
2013-09-25 08:47:54 -0600 | asked a question | App Crashes when I try to get RGB values from cv::Mat I I am trying to get the R,G & B values of a pixel in a cv::Mat. Here is the method to get the value of B: int blue = img.at<cv::vec3b>(row,col)[0]; The app Crashes without any error log with EXC_BAD_Excess on the this statement. I also tried the following method but ran into same problem:( uchar b = frame.data[frame.channels()frame.colsy + x + 0]; I have successfully added the opencv2.framework in my project. I have added the compiler flags to compile for objective-C++and the normal conversions from cv::Mat to UIImage and vice versa are working fine. Can any one please help me figure out the reason for this crash?? Am I not allowed to use the "Mat::at(int i0, int i1)" method in Objective-C for iOS? OR is there any alternative method to get the R,G & B values from a cv::Mat? |